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       ·   Acknowledgement
89
90           All contributors are credited (by name and email address) in the
91           AUTHORS file, which is part of the perl distribution, as well as
92           the Git commit history.
93
94           If you donXt want to be included in the AUTHORS file, just let us
95           know. Otherwise we will take your submission of a patch as
96           permission to credit you in the AUTHORS file.
97
98       ·   Next time
99
100           The next time you wish to make a patch, you need to start from the
101           latest perl in a pristine state.  Check you don't have any local
102           changes or added files in your perl check-out which you wish to
103           keep, then run these commands:
104
105             % git pull
106             % git reset --hard origin/blead
107             % git clean -dxf
108

BUG REPORTING

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

PERL 5 PORTERS

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

GETTING THE PERL SOURCE

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

PATCHING PERL

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

TESTING

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

MORE READING FOR GUTS HACKERS

952       To hack on the Perl guts, you'll need to read the following things:
953
954       ·   perlsource
955
956           An overview of the Perl source tree.  This will help you find the
957           files you're looking for.
958
959       ·   perlinterp
960
961           An overview of the Perl interpreter source code and some details on
962           how Perl does what it does.
963
964       ·   perlhacktut
965
966           This document walks through the creation of a small patch to Perl's
967           C code.  If you're just getting started with Perl core hacking,
968           this will help you understand how it works.
969
970       ·   perlhacktips
971
972           More details on hacking the Perl core.  This document focuses on
973           lower level details such as how to write tests, compilation issues,
974           portability, debugging, etc.
975
976           If you plan on doing serious C hacking, make sure to read this.
977
978       ·   perlguts
979
980           This is of paramount importance, since it's the documentation of
981           what goes where in the Perl source.  Read it over a couple of times
982           and it might start to make sense - don't worry if it doesn't yet,
983           because the best way to study it is to read it in conjunction with
984           poking at Perl source, and we'll do that later on.
985
986           Gisle Aas's "illustrated perlguts", also known as illguts, has very
987           helpful pictures:
988
989           <http://search.cpan.org/dist/illguts/>
990
991       ·   perlxstut and perlxs
992
993           A working knowledge of XSUB programming is incredibly useful for
994           core hacking; XSUBs use techniques drawn from the PP code, the
995           portion of the guts that actually executes a Perl program.  It's a
996           lot gentler to learn those techniques from simple examples and
997           explanation than from the core itself.
998
999       ·   perlapi
1000
1001           The documentation for the Perl API explains what some of the
1002           internal functions do, as well as the many macros used in the
1003           source.
1004
1005       ·   Porting/pumpkin.pod
1006
1007           This is a collection of words of wisdom for a Perl porter; some of
1008           it is only useful to the pumpkin holder, but most of it applies to
1009           anyone wanting to go about Perl development.
1010

CPAN TESTERS AND PERL SMOKERS

1012       The CPAN testers ( <http://testers.cpan.org/> ) are a group of
1013       volunteers who test CPAN modules on a variety of platforms.
1014
1015       Perl Smokers ( <http://www.nntp.perl.org/group/perl.daily-build/> and
1016       <http://www.nntp.perl.org/group/perl.daily-build.reports/> )
1017       automatically test Perl source releases on platforms with various
1018       configurations.
1019
1020       Both efforts welcome volunteers.  In order to get involved in smoke
1021       testing of the perl itself visit
1022       <http://search.cpan.org/dist/Test-Smoke/>.  In order to start smoke
1023       testing CPAN modules visit
1024       <http://search.cpan.org/dist/CPANPLUS-YACSmoke/> or
1025       <http://search.cpan.org/dist/minismokebox/> or
1026       <http://search.cpan.org/dist/CPAN-Reporter/>.
1027

WHAT NEXT?

1029       If you've read all the documentation in the document and the ones
1030       listed above, you're more than ready to hack on Perl.
1031
1032       Here's some more recommendations
1033
1034       ·   Subscribe to perl5-porters, follow the patches and try and
1035           understand them; don't be afraid to ask if there's a portion you're
1036           not clear on - who knows, you may unearth a bug in the patch...
1037
1038       ·   Do read the README associated with your operating system, e.g.
1039           README.aix on the IBM AIX OS.  Don't hesitate to supply patches to
1040           that README if you find anything missing or changed over a new OS
1041           release.
1042
1043       ·   Find an area of Perl that seems interesting to you, and see if you
1044           can work out how it works.  Scan through the source, and step over
1045           it in the debugger.  Play, poke, investigate, fiddle! You'll
1046           probably get to understand not just your chosen area but a much
1047           wider range of perl's activity as well, and probably sooner than
1048           you'd think.
1049
1050   "The Road goes ever on and on, down from the door where it began."
1051       If you can do these things, you've started on the long road to Perl
1052       porting.  Thanks for wanting to help make Perl better - and happy
1053       hacking!
1054
1055   Metaphoric Quotations
1056       If you recognized the quote about the Road above, you're in luck.
1057
1058       Most software projects begin each file with a literal description of
1059       each file's purpose.  Perl instead begins each with a literary allusion
1060       to that file's purpose.
1061
1062       Like chapters in many books, all top-level Perl source files (along
1063       with a few others here and there) begin with an epigrammatic
1064       inscription that alludes, indirectly and metaphorically, to the
1065       material you're about to read.
1066
1067       Quotations are taken from writings of J.R.R. Tolkien pertaining to his
1068       Legendarium, almost always from The Lord of the Rings.  Chapters and
1069       page numbers are given using the following editions:
1070
1071       ·   The Hobbit, by J.R.R. Tolkien.  The hardcover, 70th-anniversary
1072           edition of 2007 was used, published in the UK by Harper Collins
1073           Publishers and in the US by the Houghton Mifflin Company.
1074
1075       ·   The Lord of the Rings, by J.R.R. Tolkien.  The hardcover,
1076           50th-anniversary edition of 2004 was used, published in the UK by
1077           Harper Collins Publishers and in the US by the Houghton Mifflin
1078           Company.
1079
1080       ·   The Lays of Beleriand, by J.R.R. Tolkien and published posthumously
1081           by his son and literary executor, C.J.R. Tolkien, being the 3rd of
1082           the 12 volumes in Christopher's mammoth History of Middle Earth.
1083           Page numbers derive from the hardcover edition, first published in
1084           1983 by George Allen & Unwin; no page numbers changed for the
1085           special 3-volume omnibus edition of 2002 or the various trade-paper
1086           editions, all again now by Harper Collins or Houghton Mifflin.
1087
1088       Other JRRT books fair game for quotes would thus include The Adventures
1089       of Tom Bombadil, The Silmarillion, Unfinished Tales, and The Tale of
1090       the Children of Hurin, all but the first posthumously assembled by
1091       CJRT.  But The Lord of the Rings itself is perfectly fine and probably
1092       best to quote from, provided you can find a suitable quote there.
1093
1094       So if you were to supply a new, complete, top-level source file to add
1095       to Perl, you should conform to this peculiar practice by yourself
1096       selecting an appropriate quotation from Tolkien, retaining the original
1097       spelling and punctuation and using the same format the rest of the
1098       quotes are in.  Indirect and oblique is just fine; remember, it's a
1099       metaphor, so being meta is, after all, what it's for.
1100

AUTHOR

1102       This document was originally written by Nathan Torkington, and is
1103       maintained by the perl5-porters mailing list.
1104
1105
1106
1107perl v5.28.2                      2018-11-01                       PERLHACK(1)
Impressum