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 Perl bug
11       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 https://github.com/Perl/perl5.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       •   Create a branch for your change
33
34           Create a branch based on blead to commit your change to, which will
35           later be used to send it to the Perl issue tracker.
36
37             % git checkout -b mychange
38
39       •   Make your change
40
41           Hack, hack, hack.  Keep in mind that Perl runs on many different
42           platforms, with different operating systems that have different
43           capabilities, different filesystem organizations, and even
44           different character sets.  perlhacktips gives advice on this.
45
46       •   Test your change
47
48           You can run all the tests with the following commands:
49
50             % ./Configure -des -Dusedevel
51             % make test
52
53           Keep hacking until the tests pass.
54
55       •   Commit your change
56
57           Committing your work will save the change on your local system:
58
59             % git commit -a -m 'Commit message goes here'
60
61           Make sure the commit message describes your change in a single
62           sentence.  For example, "Fixed spelling errors in perlhack.pod".
63
64       •   Send your change to the Perl issue tracker
65
66           The next step is to submit your patch to the Perl core ticket
67           system.
68
69           Create a GitHub fork of the perl5 repository and add it as a
70           remote, if you haven't already, as described in the GitHub
71           documentation at
72           <https://help.github.com/en/articles/working-with-forks>.
73
74             % git remote add fork git@github.com:MyUser/perl5.git
75
76           For more information, see "Connecting to GitHub with SSH"
77           <https://docs.github.com/en/free-pro-
78           team@latest/github/authenticating-to-github/connecting-to-github-
79           with-ssh>.
80
81           If you'd rather use an HTTPS URL for your "git push" see "Cloning
82           with HTTPS URLs" <https://docs.github.com/en/free-pro-
83           team@latest/github/using-git/which-remote-url-should-i-use#cloning-
84           with-https-urls>.
85
86             % git remote add fork https://github.com/MyUser/perl5.git
87
88           Then, push your new branch to your fork.
89
90             % git push -u fork mychange
91
92           Finally, create a Pull Request on GitHub from your branch to blead
93           as described in the GitHub documentation at
94           <https://help.github.com/en/articles/creating-a-pull-request-from-a-fork>.
95
96       •   Thank you
97
98           The porters appreciate the time you spent helping to make Perl
99           better.  Thank you!
100
101       •   Acknowledgement
102
103           All contributors are credited (by name and email address) in the
104           AUTHORS file, which is part of the perl distribution, as well as
105           the Git commit history.
106
107           If you donXt want to be included in the AUTHORS file, just let us
108           know. Otherwise we will take your submission of a patch as
109           permission to credit you in the AUTHORS file.
110
111       •   Next time
112
113           The next time you wish to make a patch, you need to start from the
114           latest perl in a pristine state.  Check you don't have any local
115           changes or added files in your perl check-out which you wish to
116           keep, then run these commands:
117
118             % git checkout blead
119             % git pull
120             % git reset --hard origin/blead
121             % git clean -dxf
122

BUG REPORTING

124       If you want to report a bug in Perl, or browse existing Perl bugs and
125       patches, use the GitHub issue tracker at
126       <https://github.com/perl/perl5/issues>.
127
128       Please check the archive of the perl5-porters list (see below) and/or
129       the bug tracking system before submitting a bug report.  Often, you'll
130       find that the bug has been reported already.
131
132       You can log in to the bug tracking system and comment on existing bug
133       reports.  If you have additional information regarding an existing bug,
134       please add it.  This will help the porters fix the bug.
135

PERL 5 PORTERS

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

GETTING THE PERL SOURCE

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

PATCHING PERL

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

TESTING

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

MORE READING FOR GUTS HACKERS

978       To hack on the Perl guts, you'll need to read the following things:
979
980       •   perlsource
981
982           An overview of the Perl source tree.  This will help you find the
983           files you're looking for.
984
985       •   perlinterp
986
987           An overview of the Perl interpreter source code and some details on
988           how Perl does what it does.
989
990       •   perlhacktut
991
992           This document walks through the creation of a small patch to Perl's
993           C code.  If you're just getting started with Perl core hacking,
994           this will help you understand how it works.
995
996       •   perlhacktips
997
998           More details on hacking the Perl core.  This document focuses on
999           lower level details such as how to write tests, compilation issues,
1000           portability, debugging, etc.
1001
1002           If you plan on doing serious C hacking, make sure to read this.
1003
1004       •   perlguts
1005
1006           This is of paramount importance, since it's the documentation of
1007           what goes where in the Perl source.  Read it over a couple of times
1008           and it might start to make sense - don't worry if it doesn't yet,
1009           because the best way to study it is to read it in conjunction with
1010           poking at Perl source, and we'll do that later on.
1011
1012           Gisle Aas's "illustrated perlguts", also known as illguts, has very
1013           helpful pictures:
1014
1015           <https://metacpan.org/release/RURBAN/illguts-0.49>
1016
1017       •   perlxstut and perlxs
1018
1019           A working knowledge of XSUB programming is incredibly useful for
1020           core hacking; XSUBs use techniques drawn from the PP code, the
1021           portion of the guts that actually executes a Perl program.  It's a
1022           lot gentler to learn those techniques from simple examples and
1023           explanation than from the core itself.
1024
1025       •   perlapi
1026
1027           The documentation for the Perl API explains what some of the
1028           internal functions do, as well as the many macros used in the
1029           source.
1030
1031Porting/pumpkin.pod
1032
1033           This is a collection of words of wisdom for a Perl porter; some of
1034           it is only useful to the pumpkin holders, but most of it applies to
1035           anyone wanting to go about Perl development.
1036

CPAN TESTERS AND PERL SMOKERS

1038       The CPAN testers ( <http://cpantesters.org/> ) are a group of
1039       volunteers who test CPAN modules on a variety of platforms.
1040
1041       Perl Smokers ( <https://www.nntp.perl.org/group/perl.daily-build/> and
1042       <https://www.nntp.perl.org/group/perl.daily-build.reports/> )
1043       automatically test Perl source releases on platforms with various
1044       configurations.
1045
1046       Both efforts welcome volunteers.  In order to get involved in smoke
1047       testing of the perl itself visit
1048       <https://metacpan.org/release/Test-Smoke>.  In order to start smoke
1049       testing CPAN modules visit
1050       <https://metacpan.org/release/CPANPLUS-YACSmoke> or
1051       <https://metacpan.org/release/minismokebox> or
1052       <https://metacpan.org/release/CPAN-Reporter>.
1053

WHAT NEXT?

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

AUTHOR

1128       This document was originally written by Nathan Torkington, and is
1129       maintained by the perl5-porters mailing list.
1130
1131
1132
1133perl v5.34.1                      2022-03-15                       PERLHACK(1)
Impressum