1PERLHACK(1)            Perl Programmers Reference Guide            PERLHACK(1)
2
3
4

NAME

6       perlhack - How to hack on Perl
7

DESCRIPTION

9       This document explains how Perl development works.  It includes details
10       about the Perl 5 Porters email list, the Perl repository, the Perlbug
11       bug tracker, patch guidelines, and commentary on Perl development
12       philosophy.
13

SUPER QUICK PATCH GUIDE

15       If you just want to submit a single small patch like a pod fix, a test
16       for a bug, comment fixes, etc., it's easy! Here's how:
17
18       ·   Check out the source repository
19
20           The perl source is in a git repository.  You can clone the
21           repository with the following command:
22
23             % git clone git://perl5.git.perl.org/perl.git perl
24
25       ·   Ensure you're following the latest advice
26
27           In case the advice in this guide has been updated recently, read
28           the latest version directly from the perl source:
29
30             % perldoc pod/perlhack.pod
31
32       ·   Make your change
33
34           Hack, hack, hack.  Keep in mind that Perl runs on many different
35           platforms, with different operating systems that have different
36           capabilities, different filesystem organizations, and even
37           different character sets.  perlhacktips gives advice on this.
38
39       ·   Test your change
40
41           You can run all the tests with the following commands:
42
43             % ./Configure -des -Dusedevel
44             % make test
45
46           Keep hacking until the tests pass.
47
48       ·   Commit your change
49
50           Committing your work will save the change on your local system:
51
52             % git commit -a -m 'Commit message goes here'
53
54           Make sure the commit message describes your change in a single
55           sentence.  For example, "Fixed spelling errors in perlhack.pod".
56
57       ·   Send your change to perlbug
58
59           The next step is to submit your patch to the Perl core ticket
60           system via email.
61
62           If your changes are in a single git commit, run the following
63           commands to generate the patch file and attach it to your bug
64           report:
65
66             % git format-patch -1
67             % ./perl -Ilib utils/perlbug -p 0001-*.patch
68
69           The perlbug program will ask you a few questions about your email
70           address and the patch you're submitting.  Once you've answered them
71           it will submit your patch via email.
72
73           If your changes are in multiple commits, generate a patch file for
74           each one and provide them to perlbug's "-p" option separated by
75           commas:
76
77             % git format-patch -3
78             % ./perl -Ilib utils/perlbug -p 0001-fix1.patch,0002-fix2.patch,\
79             > 0003-fix3.patch
80
81           When prompted, pick a subject that summarizes your changes.
82
83       ·   Thank you
84
85           The porters appreciate the time you spent helping to make Perl
86           better.  Thank you!
87
88       ·   Next time
89
90           The next time you wish to make a patch, you need to start from the
91           latest perl in a pristine state.  Check you don't have any local
92           changes or added files in your perl check-out which you wish to
93           keep, then run these commands:
94
95             % git pull
96             % git reset --hard origin/blead
97             % git clean -dxf
98

BUG REPORTING

100       If you want to report a bug in Perl, you must use the perlbug command
101       line tool.  This tool will ensure that your bug report includes all the
102       relevant system and configuration information.
103
104       To browse existing Perl bugs and patches, you can use the web interface
105       at <http://rt.perl.org/>.
106
107       Please check the archive of the perl5-porters list (see below) and/or
108       the bug tracking system before submitting a bug report.  Often, you'll
109       find that the bug has been reported already.
110
111       You can log in to the bug tracking system and comment on existing bug
112       reports.  If you have additional information regarding an existing bug,
113       please add it.  This will help the porters fix the bug.
114

PERL 5 PORTERS

116       The perl5-porters (p5p) mailing list is where the Perl standard
117       distribution is maintained and developed.  The people who maintain Perl
118       are also referred to as the "Perl 5 Porters", "p5p" or just the
119       "porters".
120
121       A searchable archive of the list is available at
122       <http://markmail.org/search/?q=perl5-porters>.  There is also an
123       archive at <http://archive.develooper.com/perl5-porters@perl.org/>.
124
125   perl-changes mailing list
126       The perl5-changes mailing list receives a copy of each patch that gets
127       submitted to the maintenance and development branches of the perl
128       repository.  See <http://lists.perl.org/list/perl5-changes.html> for
129       subscription and archive information.
130
131   #p5p on IRC
132       Many porters are also active on the <irc://irc.perl.org/#p5p> channel.
133       Feel free to join the channel and ask questions about hacking on the
134       Perl core.
135

GETTING THE PERL SOURCE

137       All of Perl's source code is kept centrally in a Git repository at
138       perl5.git.perl.org.  The repository contains many Perl revisions from
139       Perl 1 onwards and all the revisions from Perforce, the previous
140       version control system.
141
142       For much more detail on using git with the Perl repository, please see
143       perlgit.
144
145   Read access via Git
146       You will need a copy of Git for your computer.  You can fetch a copy of
147       the repository using the git protocol:
148
149         % git clone git://perl5.git.perl.org/perl.git perl
150
151       This clones the repository and makes a local copy in the perl
152       directory.
153
154       If you cannot use the git protocol for firewall reasons, you can also
155       clone via http, though this is much slower:
156
157         % git clone http://perl5.git.perl.org/perl.git perl
158
159   Read access via the web
160       You may access the repository over the web.  This allows you to browse
161       the tree, see recent commits, subscribe to RSS feeds for the changes,
162       search for particular commits and more.  You may access it at
163       <http://perl5.git.perl.org/perl.git>.  A mirror of the repository is
164       found at <https://github.com/Perl/perl5>.
165
166   Read access via rsync
167       You can also choose to use rsync to get a copy of the current source
168       tree for the bleadperl branch and all maintenance branches:
169
170         % rsync -avz rsync://perl5.git.perl.org/perl-current .
171         % rsync -avz rsync://perl5.git.perl.org/perl-5.12.x .
172         % rsync -avz rsync://perl5.git.perl.org/perl-5.10.x .
173         % rsync -avz rsync://perl5.git.perl.org/perl-5.8.x .
174         % rsync -avz rsync://perl5.git.perl.org/perl-5.6.x .
175         % rsync -avz rsync://perl5.git.perl.org/perl-5.005xx .
176
177       (Add the "--delete" option to remove leftover files.)
178
179       To get a full list of the available sync points:
180
181         % rsync perl5.git.perl.org::
182
183   Write access via git
184       If you have a commit bit, please see perlgit for more details on using
185       git.
186

PATCHING PERL

188       If you're planning to do more extensive work than a single small fix,
189       we encourage you to read the documentation below.  This will help you
190       focus your work and make your patches easier to incorporate into the
191       Perl source.
192
193   Submitting patches
194       If you have a small patch to submit, please submit it via perlbug.  You
195       can also send email directly to perlbug@perl.org.  Please note that
196       messages sent to perlbug may be held in a moderation queue, so you
197       won't receive a response immediately.
198
199       You'll know your submission has been processed when you receive an
200       email from our ticket tracking system.  This email will give you a
201       ticket number.  Once your patch has made it to the ticket tracking
202       system, it will also be sent to the perl5-porters@perl.org list.
203
204       Patches are reviewed and discussed on the p5p list.  Simple,
205       uncontroversial patches will usually be applied without any discussion.
206       When the patch is applied, the ticket will be updated and you will
207       receive email.  In addition, an email will be sent to the p5p list.
208
209       In other cases, the patch will need more work or discussion.  That will
210       happen on the p5p list.
211
212       You are encouraged to participate in the discussion and advocate for
213       your patch.  Sometimes your patch may get lost in the shuffle.  It's
214       appropriate to send a reminder email to p5p if no action has been taken
215       in a month.  Please remember that the Perl 5 developers are all
216       volunteers, and be polite.
217
218       Changes are always applied directly to the main development branch,
219       called "blead".  Some patches may be backported to a maintenance
220       branch.  If you think your patch is appropriate for the maintenance
221       branch (see "MAINTENANCE BRANCHES" in perlpolicy), please explain why
222       when you submit it.
223
224   Getting your patch accepted
225       If you are submitting a code patch there are several things that you
226       can do to help the Perl 5 Porters accept your patch.
227
228       Patch style
229
230       If you used git to check out the Perl source, then using "git
231       format-patch" will produce a patch in a style suitable for Perl.  The
232       "format-patch" command produces one patch file for each commit you
233       made.  If you prefer to send a single patch for all commits, you can
234       use "git diff".
235
236         % git checkout blead
237         % git pull
238         % git diff blead my-branch-name
239
240       This produces a patch based on the difference between blead and your
241       current branch.  It's important to make sure that blead is up to date
242       before producing the diff, that's why we call "git pull" first.
243
244       We strongly recommend that you use git if possible.  It will make your
245       life easier, and ours as well.
246
247       However, if you're not using git, you can still produce a suitable
248       patch.  You'll need a pristine copy of the Perl source to diff against.
249       The porters prefer unified diffs.  Using GNU "diff", you can produce a
250       diff like this:
251
252         % diff -Npurd perl.pristine perl.mine
253
254       Make sure that you "make realclean" in your copy of Perl to remove any
255       build artifacts, or you may get a confusing result.
256
257       Commit message
258
259       As you craft each patch you intend to submit to the Perl core, it's
260       important to write a good commit message.  This is especially important
261       if your submission will consist of a series of commits.
262
263       The first line of the commit message should be a short description
264       without a period.  It should be no longer than the subject line of an
265       email, 50 characters being a good rule of thumb.
266
267       A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will
268       only display the first line (cut off at 50 characters) when presenting
269       commit summaries.
270
271       The commit message should include a description of the problem that the
272       patch corrects or new functionality that the patch adds.
273
274       As a general rule of thumb, your commit message should help a
275       programmer who knows the Perl core quickly understand what you were
276       trying to do, how you were trying to do it, and why the change matters
277       to Perl.
278
279       ·   Why
280
281           Your commit message should describe why the change you are making
282           is important.  When someone looks at your change in six months or
283           six years, your intent should be clear.
284
285           If you're deprecating a feature with the intent of later
286           simplifying another bit of code, say so.  If you're fixing a
287           performance problem or adding a new feature to support some other
288           bit of the core, mention that.
289
290       ·   What
291
292           Your commit message should describe what part of the Perl core
293           you're changing and what you expect your patch to do.
294
295       ·   How
296
297           While it's not necessary for documentation changes, new tests or
298           trivial patches, it's often worth explaining how your change works.
299           Even if it's clear to you today, it may not be clear to a porter
300           next month or next year.
301
302       A commit message isn't intended to take the place of comments in your
303       code.  Commit messages should describe the change you made, while code
304       comments should describe the current state of the code.
305
306       If you've just implemented a new feature, complete with doc, tests and
307       well-commented code, a brief commit message will often suffice.  If,
308       however, you've just changed a single character deep in the parser or
309       lexer, you might need to write a small novel to ensure that future
310       readers understand what you did and why you did it.
311
312       Comments, Comments, Comments
313
314       Be sure to adequately comment your code.  While commenting every line
315       is unnecessary, anything that takes advantage of side effects of
316       operators, that creates changes that will be felt outside of the
317       function being patched, or that others may find confusing should be
318       documented.  If you are going to err, it is better to err on the side
319       of adding too many comments than too few.
320
321       The best comments explain why the code does what it does, not what it
322       does.
323
324       Style
325
326       In general, please follow the particular style of the code you are
327       patching.
328
329       In particular, follow these general guidelines for patching Perl
330       sources:
331
332       ·   4-wide indents for code, 2-wide indents for nested CPP "#define"s,
333           with 8-wide tabstops.
334
335       ·   Use spaces for indentation, not tab characters.
336
337           The codebase is a mixture of tabs and spaces for indentation, and
338           we are moving to spaces only.  Converting lines you're patching
339           from 8-wide tabs to spaces will help this migration.
340
341       ·   Try hard not to exceed 79-columns
342
343       ·   ANSI C prototypes
344
345       ·   Uncuddled elses and "K&R" style for indenting control constructs
346
347       ·   No C++ style (//) comments
348
349       ·   Mark places that need to be revisited with XXX (and revisit often!)
350
351       ·   Opening brace lines up with "if" when conditional spans multiple
352           lines; should be at end-of-line otherwise
353
354       ·   In function definitions, name starts in column 0 (return value-type
355           is on previous line)
356
357       ·   Single space after keywords that are followed by parens, no space
358           between function name and following paren
359
360       ·   Avoid assignments in conditionals, but if they're unavoidable, use
361           extra paren, e.g. "if (a && (b = c)) ..."
362
363       ·   "return foo;" rather than "return(foo);"
364
365       ·   "if (!foo) ..." rather than "if (foo == FALSE) ..." etc.
366
367       ·   Do not declare variables using "register".  It may be
368           counterproductive with modern compilers, and is deprecated in C++,
369           under which the Perl source is regularly compiled.
370
371       ·   In-line functions that are in headers that are accessible to XS
372           code need to be able to compile without warnings with commonly used
373           extra compilation flags, such as gcc's "-Wswitch-default" which
374           warns whenever a switch statement does not have a "default" case.
375           The use of these extra flags is to catch potential problems in
376           legal C code, and is often used by Perl aggregators, such as Linux
377           distributors.
378
379       Test suite
380
381       If your patch changes code (rather than just changing documentation),
382       you should also include one or more test cases which illustrate the bug
383       you're fixing or validate the new functionality you're adding.  In
384       general, you should update an existing test file rather than create a
385       new one.
386
387       Your test suite additions should generally follow these guidelines
388       (courtesy of Gurusamy Sarathy <gsar@activestate.com>):
389
390       ·   Know what you're testing.  Read the docs, and the source.
391
392       ·   Tend to fail, not succeed.
393
394       ·   Interpret results strictly.
395
396       ·   Use unrelated features (this will flush out bizarre interactions).
397
398       ·   Use non-standard idioms (otherwise you are not testing TIMTOWTDI).
399
400       ·   Avoid using hardcoded test numbers whenever possible (the
401           EXPECTED/GOT found in t/op/tie.t is much more maintainable, and
402           gives better failure reports).
403
404       ·   Give meaningful error messages when a test fails.
405
406       ·   Avoid using qx// and system() unless you are testing for them.  If
407           you do use them, make sure that you cover _all_ perl platforms.
408
409       ·   Unlink any temporary files you create.
410
411       ·   Promote unforeseen warnings to errors with $SIG{__WARN__}.
412
413       ·   Be sure to use the libraries and modules shipped with the version
414           being tested, not those that were already installed.
415
416       ·   Add comments to the code explaining what you are testing for.
417
418       ·   Make updating the '1..42' string unnecessary.  Or make sure that
419           you update it.
420
421       ·   Test _all_ behaviors of a given operator, library, or function.
422
423           Test all optional arguments.
424
425           Test return values in various contexts (boolean, scalar, list,
426           lvalue).
427
428           Use both global and lexical variables.
429
430           Don't forget the exceptional, pathological cases.
431
432   Patching a core module
433       This works just like patching anything else, with one extra
434       consideration.
435
436       Modules in the cpan/ directory of the source tree are maintained
437       outside of the Perl core.  When the author updates the module, the
438       updates are simply copied into the core.  See that module's
439       documentation or its listing on <http://search.cpan.org/> for more
440       information on reporting bugs and submitting patches.
441
442       In most cases, patches to modules in cpan/ should be sent upstream and
443       should not be applied to the Perl core individually.  If a patch to a
444       file in cpan/ absolutely cannot wait for the fix to be made upstream,
445       released to CPAN and copied to blead, you must add (or update) a
446       "CUSTOMIZED" entry in the "Porting/Maintainers.pl" file to flag that a
447       local modification has been made.  See "Porting/Maintainers.pl" for
448       more details.
449
450       In contrast, modules in the dist/ directory are maintained in the core.
451
452   Updating perldelta
453       For changes significant enough to warrant a pod/perldelta.pod entry,
454       the porters will greatly appreciate it if you submit a delta entry
455       along with your actual change.  Significant changes include, but are
456       not limited to:
457
458       ·   Adding, deprecating, or removing core features
459
460       ·   Adding, deprecating, removing, or upgrading core or dual-life
461           modules
462
463       ·   Adding new core tests
464
465       ·   Fixing security issues and user-visible bugs in the core
466
467       ·   Changes that might break existing code, either on the perl or C
468           level
469
470       ·   Significant performance improvements
471
472       ·   Adding, removing, or significantly changing documentation in the
473           pod/ directory
474
475       ·   Important platform-specific changes
476
477       Please make sure you add the perldelta entry to the right section
478       within pod/perldelta.pod.  More information on how to write good
479       perldelta entries is available in the "Style" section of
480       Porting/how_to_write_a_perldelta.pod.
481
482   What makes for a good patch?
483       New features and extensions to the language can be contentious.  There
484       is no specific set of criteria which determine what features get added,
485       but here are some questions to consider when developing a patch:
486
487       Does the concept match the general goals of Perl?
488
489       Our goals include, but are not limited to:
490
491       1.  Keep it fast, simple, and useful.
492
493       2.  Keep features/concepts as orthogonal as possible.
494
495       3.  No arbitrary limits (platforms, data sizes, cultures).
496
497       4.  Keep it open and exciting to use/patch/advocate Perl everywhere.
498
499       5.  Either assimilate new technologies, or build bridges to them.
500
501       Where is the implementation?
502
503       All the talk in the world is useless without an implementation.  In
504       almost every case, the person or people who argue for a new feature
505       will be expected to be the ones who implement it.  Porters capable of
506       coding new features have their own agendas, and are not available to
507       implement your (possibly good) idea.
508
509       Backwards compatibility
510
511       It's a cardinal sin to break existing Perl programs.  New warnings can
512       be contentious--some say that a program that emits warnings is not
513       broken, while others say it is.  Adding keywords has the potential to
514       break programs, changing the meaning of existing token sequences or
515       functions might break programs.
516
517       The Perl 5 core includes mechanisms to help porters make backwards
518       incompatible changes more compatible such as the feature and deprecate
519       modules.  Please use them when appropriate.
520
521       Could it be a module instead?
522
523       Perl 5 has extension mechanisms, modules and XS, specifically to avoid
524       the need to keep changing the Perl interpreter.  You can write modules
525       that export functions, you can give those functions prototypes so they
526       can be called like built-in functions, you can even write XS code to
527       mess with the runtime data structures of the Perl interpreter if you
528       want to implement really complicated things.
529
530       Whenever possible, new features should be prototyped in a CPAN module
531       before they will be considered for the core.
532
533       Is the feature generic enough?
534
535       Is this something that only the submitter wants added to the language,
536       or is it broadly useful?  Sometimes, instead of adding a feature with a
537       tight focus, the porters might decide to wait until someone implements
538       the more generalized feature.
539
540       Does it potentially introduce new bugs?
541
542       Radical rewrites of large chunks of the Perl interpreter have the
543       potential to introduce new bugs.
544
545       How big is it?
546
547       The smaller and more localized the change, the better.  Similarly, a
548       series of small patches is greatly preferred over a single large patch.
549
550       Does it preclude other desirable features?
551
552       A patch is likely to be rejected if it closes off future avenues of
553       development.  For instance, a patch that placed a true and final
554       interpretation on prototypes is likely to be rejected because there are
555       still options for the future of prototypes that haven't been addressed.
556
557       Is the implementation robust?
558
559       Good patches (tight code, complete, correct) stand more chance of going
560       in.  Sloppy or incorrect patches might be placed on the back burner
561       until the pumpking has time to fix, or might be discarded altogether
562       without further notice.
563
564       Is the implementation generic enough to be portable?
565
566       The worst patches make use of system-specific features.  It's highly
567       unlikely that non-portable additions to the Perl language will be
568       accepted.
569
570       Is the implementation tested?
571
572       Patches which change behaviour (fixing bugs or introducing new
573       features) must include regression tests to verify that everything works
574       as expected.
575
576       Without tests provided by the original author, how can anyone else
577       changing perl in the future be sure that they haven't unwittingly
578       broken the behaviour the patch implements? And without tests, how can
579       the patch's author be confident that his/her hard work put into the
580       patch won't be accidentally thrown away by someone in the future?
581
582       Is there enough documentation?
583
584       Patches without documentation are probably ill-thought out or
585       incomplete.  No features can be added or changed without documentation,
586       so submitting a patch for the appropriate pod docs as well as the
587       source code is important.
588
589       Is there another way to do it?
590
591       Larry said "Although the Perl Slogan is There's More Than One Way to Do
592       It, I hesitate to make 10 ways to do something".  This is a tricky
593       heuristic to navigate, though--one man's essential addition is another
594       man's pointless cruft.
595
596       Does it create too much work?
597
598       Work for the pumpking, work for Perl programmers, work for module
599       authors, ... Perl is supposed to be easy.
600
601       Patches speak louder than words
602
603       Working code is always preferred to pie-in-the-sky ideas.  A patch to
604       add a feature stands a much higher chance of making it to the language
605       than does a random feature request, no matter how fervently argued the
606       request might be.  This ties into "Will it be useful?", as the fact
607       that someone took the time to make the patch demonstrates a strong
608       desire for the feature.
609

TESTING

611       The core uses the same testing style as the rest of Perl, a simple
612       "ok/not ok" run through Test::Harness, but there are a few special
613       considerations.
614
615       There are three ways to write a test in the core: Test::More, t/test.pl
616       and ad hoc "print $test ? "ok 42\n" : "not ok 42\n"".  The decision of
617       which to use depends on what part of the test suite you're working on.
618       This is a measure to prevent a high-level failure (such as Config.pm
619       breaking) from causing basic functionality tests to fail.
620
621       The t/test.pl library provides some of the features of Test::More, but
622       avoids loading most modules and uses as few core features as possible.
623
624       If you write your own test, use the Test Anything Protocol
625       <http://testanything.org>.
626
627       ·   t/base, t/comp and t/opbasic
628
629           Since we don't know if "require" works, or even subroutines, use ad
630           hoc tests for these three.  Step carefully to avoid using the
631           feature being tested.  Tests in t/opbasic, for instance, have been
632           placed there rather than in t/op because they test functionality
633           which t/test.pl presumes has already been demonstrated to work.
634
635       ·   t/cmd, t/run, t/io and t/op
636
637           Now that basic require() and subroutines are tested, you can use
638           the t/test.pl library.
639
640           You can also use certain libraries like Config conditionally, but
641           be sure to skip the test gracefully if it's not there.
642
643       ·   Everything else
644
645           Now that the core of Perl is tested, Test::More can and should be
646           used.  You can also use the full suite of core modules in the
647           tests.
648
649       When you say "make test", Perl uses the t/TEST program to run the test
650       suite (except under Win32 where it uses t/harness instead).  All tests
651       are run from the t/ directory, not the directory which contains the
652       test.  This causes some problems with the tests in lib/, so here's some
653       opportunity for some patching.
654
655       You must be triply conscious of cross-platform concerns.  This usually
656       boils down to using File::Spec, avoiding things like "fork()" and
657       "system()" unless absolutely necessary, and not assuming that a given
658       character has a particular ordinal value (code point) or that its UTF-8
659       representation is composed of particular bytes.
660
661       There are several functions available to specify characters and code
662       points portably in tests.  The always-preloaded functions
663       "utf8::unicode_to_native()" and its inverse "utf8::native_to_unicode()"
664       take code points and translate appropriately.  The file
665       t/charset_tools.pl has several functions that can be useful.  It has
666       versions of the previous two functions that take strings as inputs --
667       not single numeric code points: "uni_to_native()" and
668       "native_to_uni()".  If you must look at the individual bytes comprising
669       a UTF-8 encoded string, "byte_utf8a_to_utf8n()" takes as input a string
670       of those bytes encoded for an ASCII platform, and returns the
671       equivalent string in the native platform.  For example,
672       "byte_utf8a_to_utf8n("\xC2\xA0")" returns the byte sequence on the
673       current platform that form the UTF-8 for "U+00A0", since "\xC2\xA0" are
674       the UTF-8 bytes on an ASCII platform for that code point.  This
675       function returns "\xC2\xA0" on an ASCII platform, and "\x80\x41" on an
676       EBCDIC 1047 one.
677
678       But easiest is, if the character is specifiable as a literal, like "A"
679       or "%", to use that; if not so specificable, you can use use "\N{}" ,
680       if the side effects aren't troublesome.  Simply specify all your
681       characters in hex, using "\N{U+ZZ}" instead of "\xZZ".  "\N{}" is the
682       Unicode name, and so it always gives you the Unicode character.
683       "\N{U+41}" is the character whose Unicode code point is 0x41, hence is
684       'A' on all platforms.  The side effects are:
685
686       ·   These select Unicode rules.  That means that in double-quotish
687           strings, the string is always converted to UTF-8 to force a Unicode
688           interpretation (you can "utf8::downgrade()" afterwards to convert
689           back to non-UTF8, if possible).  In regular expression patterns,
690           the conversion isn't done, but if the character set modifier would
691           otherwise be "/d", it is changed to "/u".
692
693       ·   If you use the form "\N{character name}", the charnames module gets
694           automatically loaded.  This may not be suitable for the test level
695           you are doing.
696
697       If you are testing locales (see perllocale), there are helper functions
698       in t/loc_tools.pl to enable you to see what locales there are on the
699       current platform.
700
701   Special "make test" targets
702       There are various special make targets that can be used to test Perl
703       slightly differently than the standard "test" target.  Not all them are
704       expected to give a 100% success rate.  Many of them have several
705       aliases, and many of them are not available on certain operating
706       systems.
707
708       ·   test_porting
709
710           This runs some basic sanity tests on the source tree and helps
711           catch basic errors before you submit a patch.
712
713       ·   minitest
714
715           Run miniperl on t/base, t/comp, t/cmd, t/run, t/io, t/op, t/uni and
716           t/mro tests.
717
718       ·   test.valgrind check.valgrind
719
720           (Only in Linux) Run all the tests using the memory leak + naughty
721           memory access tool "valgrind".  The log files will be named
722           testname.valgrind.
723
724       ·   test_harness
725
726           Run the test suite with the t/harness controlling program, instead
727           of t/TEST.  t/harness is more sophisticated, and uses the
728           Test::Harness module, thus using this test target supposes that
729           perl mostly works.  The main advantage for our purposes is that it
730           prints a detailed summary of failed tests at the end.  Also, unlike
731           t/TEST, it doesn't redirect stderr to stdout.
732
733           Note that under Win32 t/harness is always used instead of t/TEST,
734           so there is no special "test_harness" target.
735
736           Under Win32's "test" target you may use the TEST_SWITCHES and
737           TEST_FILES environment variables to control the behaviour of
738           t/harness.  This means you can say
739
740               nmake test TEST_FILES="op/*.t"
741               nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t"
742
743       ·   test-notty test_notty
744
745           Sets PERL_SKIP_TTY_TEST to true before running normal test.
746
747   Parallel tests
748       The core distribution can now run its regression tests in parallel on
749       Unix-like platforms.  Instead of running "make test", set "TEST_JOBS"
750       in your environment to the number of tests to run in parallel, and run
751       "make test_harness".  On a Bourne-like shell, this can be done as
752
753           TEST_JOBS=3 make test_harness  # Run 3 tests in parallel
754
755       An environment variable is used, rather than parallel make itself,
756       because TAP::Harness needs to be able to schedule individual non-
757       conflicting test scripts itself, and there is no standard interface to
758       "make" utilities to interact with their job schedulers.
759
760       Note that currently some test scripts may fail when run in parallel
761       (most notably dist/IO/t/io_dir.t).  If necessary, run just the failing
762       scripts again sequentially and see if the failures go away.
763
764   Running tests by hand
765       You can run part of the test suite by hand by using one of the
766       following commands from the t/ directory:
767
768           ./perl -I../lib TEST list-of-.t-files
769
770       or
771
772           ./perl -I../lib harness list-of-.t-files
773
774       (If you don't specify test scripts, the whole test suite will be run.)
775
776   Using t/harness for testing
777       If you use "harness" for testing, you have several command line options
778       available to you.  The arguments are as follows, and are in the order
779       that they must appear if used together.
780
781           harness -v -torture -re=pattern LIST OF FILES TO TEST
782           harness -v -torture -re LIST OF PATTERNS TO MATCH
783
784       If "LIST OF FILES TO TEST" is omitted, the file list is obtained from
785       the manifest.  The file list may include shell wildcards which will be
786       expanded out.
787
788       ·   -v
789
790           Run the tests under verbose mode so you can see what tests were
791           run, and debug output.
792
793       ·   -torture
794
795           Run the torture tests as well as the normal set.
796
797       ·   -re=PATTERN
798
799           Filter the file list so that all the test files run match PATTERN.
800           Note that this form is distinct from the -re LIST OF PATTERNS form
801           below in that it allows the file list to be provided as well.
802
803       ·   -re LIST OF PATTERNS
804
805           Filter the file list so that all the test files run match
806           /(LIST|OF|PATTERNS)/.  Note that with this form the patterns are
807           joined by '|' and you cannot supply a list of files, instead the
808           test files are obtained from the MANIFEST.
809
810       You can run an individual test by a command similar to
811
812           ./perl -I../lib path/to/foo.t
813
814       except that the harnesses set up some environment variables that may
815       affect the execution of the test:
816
817       ·   PERL_CORE=1
818
819           indicates that we're running this test as part of the perl core
820           test suite.  This is useful for modules that have a dual life on
821           CPAN.
822
823       ·   PERL_DESTRUCT_LEVEL=2
824
825           is set to 2 if it isn't set already (see "PERL_DESTRUCT_LEVEL" in
826           perlhacktips).
827
828       ·   PERL
829
830           (used only by t/TEST) if set, overrides the path to the perl
831           executable that should be used to run the tests (the default being
832           ./perl).
833
834       ·   PERL_SKIP_TTY_TEST
835
836           if set, tells to skip the tests that need a terminal.  It's
837           actually set automatically by the Makefile, but can also be forced
838           artificially by running 'make test_notty'.
839
840       Other environment variables that may influence tests
841
842       ·   PERL_TEST_Net_Ping
843
844           Setting this variable runs all the Net::Ping modules tests,
845           otherwise some tests that interact with the outside world are
846           skipped.  See perl58delta.
847
848       ·   PERL_TEST_NOVREXX
849
850           Setting this variable skips the vrexx.t tests for OS2::REXX.
851
852       ·   PERL_TEST_NUMCONVERTS
853
854           This sets a variable in op/numconvert.t.
855
856       ·   PERL_TEST_MEMORY
857
858           Setting this variable includes the tests in t/bigmem/.  This should
859           be set to the number of gigabytes of memory available for testing,
860           eg.  "PERL_TEST_MEMORY=4" indicates that tests that require 4GiB of
861           available memory can be run safely.
862
863       See also the documentation for the Test and Test::Harness modules, for
864       more environment variables that affect testing.
865
866   Performance testing
867       The file t/perf/benchmarks contains snippets of perl code which are
868       intended to be benchmarked across a range of perls by the
869       Porting/bench.pl tool. If you fix or enhance a performance issue, you
870       may want to add a representative code sample to the file, then run
871       bench.pl against the previous and current perls to see what difference
872       it has made, and whether anything else has slowed down as a
873       consequence.
874
875       The file t/perf/opcount.t is designed to test whether a particular code
876       snippet has been compiled into an optree containing specified numbers
877       of particular op types. This is good for testing whether optimisations
878       which alter ops, such as converting an "aelem" op into an "aelemfast"
879       op, are really doing that.
880
881       The files t/perf/speed.t and t/re/speed.t are designed to test things
882       that run thousands of times slower if a particular optimisation is
883       broken (for example, the utf8 length cache on long utf8 strings).  Add
884       a test that will take a fraction of a second normally, and minutes
885       otherwise, causing the test file to time out on failure.
886

MORE READING FOR GUTS HACKERS

888       To hack on the Perl guts, you'll need to read the following things:
889
890       ·   perlsource
891
892           An overview of the Perl source tree.  This will help you find the
893           files you're looking for.
894
895       ·   perlinterp
896
897           An overview of the Perl interpreter source code and some details on
898           how Perl does what it does.
899
900       ·   perlhacktut
901
902           This document walks through the creation of a small patch to Perl's
903           C code.  If you're just getting started with Perl core hacking,
904           this will help you understand how it works.
905
906       ·   perlhacktips
907
908           More details on hacking the Perl core.  This document focuses on
909           lower level details such as how to write tests, compilation issues,
910           portability, debugging, etc.
911
912           If you plan on doing serious C hacking, make sure to read this.
913
914       ·   perlguts
915
916           This is of paramount importance, since it's the documentation of
917           what goes where in the Perl source.  Read it over a couple of times
918           and it might start to make sense - don't worry if it doesn't yet,
919           because the best way to study it is to read it in conjunction with
920           poking at Perl source, and we'll do that later on.
921
922           Gisle Aas's "illustrated perlguts", also known as illguts, has very
923           helpful pictures:
924
925           <http://search.cpan.org/dist/illguts/>
926
927       ·   perlxstut and perlxs
928
929           A working knowledge of XSUB programming is incredibly useful for
930           core hacking; XSUBs use techniques drawn from the PP code, the
931           portion of the guts that actually executes a Perl program.  It's a
932           lot gentler to learn those techniques from simple examples and
933           explanation than from the core itself.
934
935       ·   perlapi
936
937           The documentation for the Perl API explains what some of the
938           internal functions do, as well as the many macros used in the
939           source.
940
941       ·   Porting/pumpkin.pod
942
943           This is a collection of words of wisdom for a Perl porter; some of
944           it is only useful to the pumpkin holder, but most of it applies to
945           anyone wanting to go about Perl development.
946

CPAN TESTERS AND PERL SMOKERS

948       The CPAN testers ( <http://testers.cpan.org/> ) are a group of
949       volunteers who test CPAN modules on a variety of platforms.
950
951       Perl Smokers ( <http://www.nntp.perl.org/group/perl.daily-build/> and
952       <http://www.nntp.perl.org/group/perl.daily-build.reports/> )
953       automatically test Perl source releases on platforms with various
954       configurations.
955
956       Both efforts welcome volunteers.  In order to get involved in smoke
957       testing of the perl itself visit
958       <http://search.cpan.org/dist/Test-Smoke/>.  In order to start smoke
959       testing CPAN modules visit
960       <http://search.cpan.org/dist/CPANPLUS-YACSmoke/> or
961       <http://search.cpan.org/dist/minismokebox/> or
962       <http://search.cpan.org/dist/CPAN-Reporter/>.
963

WHAT NEXT?

965       If you've read all the documentation in the document and the ones
966       listed above, you're more than ready to hack on Perl.
967
968       Here's some more recommendations
969
970       ·   Subscribe to perl5-porters, follow the patches and try and
971           understand them; don't be afraid to ask if there's a portion you're
972           not clear on - who knows, you may unearth a bug in the patch...
973
974       ·   Do read the README associated with your operating system, e.g.
975           README.aix on the IBM AIX OS.  Don't hesitate to supply patches to
976           that README if you find anything missing or changed over a new OS
977           release.
978
979       ·   Find an area of Perl that seems interesting to you, and see if you
980           can work out how it works.  Scan through the source, and step over
981           it in the debugger.  Play, poke, investigate, fiddle! You'll
982           probably get to understand not just your chosen area but a much
983           wider range of perl's activity as well, and probably sooner than
984           you'd think.
985
986   "The Road goes ever on and on, down from the door where it began."
987       If you can do these things, you've started on the long road to Perl
988       porting.  Thanks for wanting to help make Perl better - and happy
989       hacking!
990
991   Metaphoric Quotations
992       If you recognized the quote about the Road above, you're in luck.
993
994       Most software projects begin each file with a literal description of
995       each file's purpose.  Perl instead begins each with a literary allusion
996       to that file's purpose.
997
998       Like chapters in many books, all top-level Perl source files (along
999       with a few others here and there) begin with an epigrammatic
1000       inscription that alludes, indirectly and metaphorically, to the
1001       material you're about to read.
1002
1003       Quotations are taken from writings of J.R.R. Tolkien pertaining to his
1004       Legendarium, almost always from The Lord of the Rings.  Chapters and
1005       page numbers are given using the following editions:
1006
1007       ·   The Hobbit, by J.R.R. Tolkien.  The hardcover, 70th-anniversary
1008           edition of 2007 was used, published in the UK by Harper Collins
1009           Publishers and in the US by the Houghton Mifflin Company.
1010
1011       ·   The Lord of the Rings, by J.R.R. Tolkien.  The hardcover,
1012           50th-anniversary edition of 2004 was used, published in the UK by
1013           Harper Collins Publishers and in the US by the Houghton Mifflin
1014           Company.
1015
1016       ·   The Lays of Beleriand, by J.R.R. Tolkien and published posthumously
1017           by his son and literary executor, C.J.R. Tolkien, being the 3rd of
1018           the 12 volumes in Christopher's mammoth History of Middle Earth.
1019           Page numbers derive from the hardcover edition, first published in
1020           1983 by George Allen & Unwin; no page numbers changed for the
1021           special 3-volume omnibus edition of 2002 or the various trade-paper
1022           editions, all again now by Harper Collins or Houghton Mifflin.
1023
1024       Other JRRT books fair game for quotes would thus include The Adventures
1025       of Tom Bombadil, The Silmarillion, Unfinished Tales, and The Tale of
1026       the Children of Hurin, all but the first posthumously assembled by
1027       CJRT.  But The Lord of the Rings itself is perfectly fine and probably
1028       best to quote from, provided you can find a suitable quote there.
1029
1030       So if you were to supply a new, complete, top-level source file to add
1031       to Perl, you should conform to this peculiar practice by yourself
1032       selecting an appropriate quotation from Tolkien, retaining the original
1033       spelling and punctuation and using the same format the rest of the
1034       quotes are in.  Indirect and oblique is just fine; remember, it's a
1035       metaphor, so being meta is, after all, what it's for.
1036

AUTHOR

1038       This document was originally written by Nathan Torkington, and is
1039       maintained by the perl5-porters mailing list.
1040
1041
1042
1043perl v5.26.3                      2018-03-23                       PERLHACK(1)
Impressum