4 Consistent formatting of this file is achieved with:
5 perl ./Porting/podtidy pod/perlhack.pod
9 perlhack - How to hack on Perl
13 This document explains how Perl development works. It includes details
14 about the Perl 5 Porters email list, the Perl repository, the Perlbug
15 bug tracker, patch guidelines, and commentary on Perl development
18 =head1 SUPER QUICK PATCH GUIDE
20 If you just want to submit a single small patch like a pod fix, a test
21 for a bug, comment fixes, etc., it's easy! Here's how:
25 =item * Check out the source repository
27 The perl source is in a git repository. You can clone the repository
28 with the following command:
30 % git clone git://perl5.git.perl.org/perl.git perl
32 =item * Ensure you're following the latest advice
34 In case the advice in this guide has been updated recently, read the
35 latest version directly from the perl source:
37 % perldoc pod/perlhack.pod
39 =item * Make your change
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 different
44 character sets. L<perlhacktips> gives advice on this.
46 =item * Test your change
48 You can run all the tests with the following commands:
50 % ./Configure -des -Dusedevel
53 Keep hacking until the tests pass.
55 =item * Commit your change
57 Committing your work will save the change I<on your local system>:
59 % git commit -a -m 'Commit message goes here'
61 Make sure the commit message describes your change in a single
62 sentence. For example, "Fixed spelling errors in perlhack.pod".
64 =item * Send your change to perlbug
66 The next step is to submit your patch to the Perl core ticket system
69 If your changes are in a single git commit, run the following commands
70 to generate the patch file and attach it to your bug report:
73 % ./perl -Ilib utils/perlbug -p 0001-*.patch
75 The perlbug program will ask you a few questions about your email
76 address and the patch you're submitting. Once you've answered them it
77 will submit your patch via email.
79 If your changes are in multiple commits, generate a patch file for each
80 one and provide them to perlbug's C<-p> option separated by commas:
83 % ./perl -Ilib utils/perlbug -p 0001-fix1.patch,0002-fix2.patch,\
86 When prompted, pick a subject that summarizes your changes.
90 The porters appreciate the time you spent helping to make Perl better.
95 The next time you wish to make a patch, you need to start from the
96 latest perl in a pristine state. Check you don't have any local changes
97 or added files in your perl check-out which you wish to keep, then run
101 % git reset --hard origin/blead
108 If you want to report a bug in Perl, you must use the F<perlbug>
109 command line tool. This tool will ensure that your bug report includes
110 all the relevant system and configuration information.
112 To browse existing Perl bugs and patches, you can use the web interface
113 at L<http://rt.perl.org/>.
115 Please check the archive of the perl5-porters list (see below) and/or
116 the bug tracking system before submitting a bug report. Often, you'll
117 find that the bug has been reported already.
119 You can log in to the bug tracking system and comment on existing bug
120 reports. If you have additional information regarding an existing bug,
121 please add it. This will help the porters fix the bug.
123 =head1 PERL 5 PORTERS
125 The perl5-porters (p5p) mailing list is where the Perl standard
126 distribution is maintained and developed. The people who maintain Perl
127 are also referred to as the "Perl 5 Porters", "p5p" or just the
130 A searchable archive of the list is available at
131 L<http://markmail.org/search/?q=perl5-porters>. There is also an archive at
132 L<http://archive.develooper.com/perl5-porters@perl.org/>.
134 =head2 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 L<http://lists.perl.org/list/perl5-changes.html> for
139 subscription and archive information.
143 Many porters are also active on the L<irc://irc.perl.org/#p5p> channel.
144 Feel free to join the channel and ask questions about hacking on the
147 =head1 GETTING THE PERL SOURCE
149 All of Perl's source code is kept centrally in a Git repository at
150 I<perl5.git.perl.org>. The repository contains many Perl revisions
151 from Perl 1 onwards and all the revisions from Perforce, the previous
152 version control system.
154 For much more detail on using git with the Perl repository, please see
157 =head2 Read access via Git
159 You will need a copy of Git for your computer. You can fetch a copy of
160 the repository using the git protocol:
162 % git clone git://perl5.git.perl.org/perl.git perl
164 This clones the repository and makes a local copy in the F<perl>
167 If you cannot use the git protocol for firewall reasons, you can also
168 clone via http, though this is much slower:
170 % git clone http://perl5.git.perl.org/perl.git perl
172 =head2 Read access via the web
174 You may access the repository over the web. This allows you to browse
175 the tree, see recent commits, subscribe to RSS feeds for the changes,
176 search for particular commits and more. You may access it at
177 L<http://perl5.git.perl.org/perl.git>. A mirror of the repository is
178 found at L<https://github.com/Perl/perl5>.
180 =head2 Read access via rsync
182 You can also choose to use rsync to get a copy of the current source
183 tree for the bleadperl branch and all maintenance branches:
185 % rsync -avz rsync://perl5.git.perl.org/perl-current .
186 % rsync -avz rsync://perl5.git.perl.org/perl-5.12.x .
187 % rsync -avz rsync://perl5.git.perl.org/perl-5.10.x .
188 % rsync -avz rsync://perl5.git.perl.org/perl-5.8.x .
189 % rsync -avz rsync://perl5.git.perl.org/perl-5.6.x .
190 % rsync -avz rsync://perl5.git.perl.org/perl-5.005xx .
192 (Add the C<--delete> option to remove leftover files.)
194 To get a full list of the available sync points:
196 % rsync perl5.git.perl.org::
198 =head2 Write access via git
200 If you have a commit bit, please see L<perlgit> for more details on
205 If you're planning to do more extensive work than a single small fix,
206 we encourage you to read the documentation below. This will help you
207 focus your work and make your patches easier to incorporate into the
210 =head2 Submitting patches
212 If you have a small patch to submit, please submit it via perlbug. You
213 can also send email directly to perlbug@perl.org. Please note that
214 messages sent to perlbug may be held in a moderation queue, so you
215 won't receive a response immediately.
217 You'll know your submission has been processed when you receive an
218 email from our ticket tracking system. This email will give you a
219 ticket number. Once your patch has made it to the ticket tracking
220 system, it will also be sent to the perl5-porters@perl.org list.
222 Patches are reviewed and discussed on the p5p list. Simple,
223 uncontroversial patches will usually be applied without any discussion.
224 When the patch is applied, the ticket will be updated and you will
225 receive email. In addition, an email will be sent to the p5p list.
227 In other cases, the patch will need more work or discussion. That will
228 happen on the p5p list.
230 You are encouraged to participate in the discussion and advocate for
231 your patch. Sometimes your patch may get lost in the shuffle. It's
232 appropriate to send a reminder email to p5p if no action has been taken
233 in a month. Please remember that the Perl 5 developers are all
234 volunteers, and be polite.
236 Changes are always applied directly to the main development branch,
237 called "blead". Some patches may be backported to a maintenance
238 branch. If you think your patch is appropriate for the maintenance
239 branch (see L<perlpolicy/MAINTENANCE BRANCHES>), please explain why
242 =head2 Getting your patch accepted
244 If you are submitting a code patch there are several things that you
245 can do to help the Perl 5 Porters accept your patch.
249 If you used git to check out the Perl source, then using C<git
250 format-patch> will produce a patch in a style suitable for Perl. The
251 C<format-patch> command produces one patch file for each commit you
252 made. If you prefer to send a single patch for all commits, you can
257 % git diff blead my-branch-name
259 This produces a patch based on the difference between blead and your
260 current branch. It's important to make sure that blead is up to date
261 before producing the diff, that's why we call C<git pull> first.
263 We strongly recommend that you use git if possible. It will make your
264 life easier, and ours as well.
266 However, if you're not using git, you can still produce a suitable
267 patch. You'll need a pristine copy of the Perl source to diff against.
268 The porters prefer unified diffs. Using GNU C<diff>, you can produce a
271 % diff -Npurd perl.pristine perl.mine
273 Make sure that you C<make realclean> in your copy of Perl to remove any
274 build artifacts, or you may get a confusing result.
276 =head3 Commit message
278 As you craft each patch you intend to submit to the Perl core, it's
279 important to write a good commit message. This is especially important
280 if your submission will consist of a series of commits.
282 The first line of the commit message should be a short description
283 without a period. It should be no longer than the subject line of an
284 email, 50 characters being a good rule of thumb.
286 A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will
287 only display the first line (cut off at 50 characters) when presenting
290 The commit message should include a description of the problem that the
291 patch corrects or new functionality that the patch adds.
293 As a general rule of thumb, your commit message should help a
294 programmer who knows the Perl core quickly understand what you were
295 trying to do, how you were trying to do it, and why the change matters
302 Your commit message should describe why the change you are making is
303 important. When someone looks at your change in six months or six
304 years, your intent should be clear.
306 If you're deprecating a feature with the intent of later simplifying
307 another bit of code, say so. If you're fixing a performance problem or
308 adding a new feature to support some other bit of the core, mention
313 Your commit message should describe what part of the Perl core you're
314 changing and what you expect your patch to do.
318 While it's not necessary for documentation changes, new tests or
319 trivial patches, it's often worth explaining how your change works.
320 Even if it's clear to you today, it may not be clear to a porter next
325 A commit message isn't intended to take the place of comments in your
326 code. Commit messages should describe the change you made, while code
327 comments should describe the current state of the code.
329 If you've just implemented a new feature, complete with doc, tests and
330 well-commented code, a brief commit message will often suffice. If,
331 however, you've just changed a single character deep in the parser or
332 lexer, you might need to write a small novel to ensure that future
333 readers understand what you did and why you did it.
335 =head3 Comments, Comments, Comments
337 Be sure to adequately comment your code. While commenting every line
338 is unnecessary, anything that takes advantage of side effects of
339 operators, that creates changes that will be felt outside of the
340 function being patched, or that others may find confusing should be
341 documented. If you are going to err, it is better to err on the side
342 of adding too many comments than too few.
344 The best comments explain I<why> the code does what it does, not I<what
349 In general, please follow the particular style of the code you are
352 In particular, follow these general guidelines for patching Perl
359 4-wide indents for code, 2-wide indents for nested CPP C<#define>s,
360 with 8-wide tabstops.
364 Use spaces for indentation, not tab characters.
366 The codebase is a mixture of tabs and spaces for indentation, and we
367 are moving to spaces only. Converting lines you're patching from 8-wide
368 tabs to spaces will help this migration.
372 Try hard not to exceed 79-columns
380 Uncuddled elses and "K&R" style for indenting control constructs
384 No C++ style (//) comments
388 Mark places that need to be revisited with XXX (and revisit often!)
392 Opening brace lines up with "if" when conditional spans multiple lines;
393 should be at end-of-line otherwise
397 In function definitions, name starts in column 0 (return value-type is on
402 Single space after keywords that are followed by parens, no space
403 between function name and following paren
407 Avoid assignments in conditionals, but if they're unavoidable, use
408 extra paren, e.g. "if (a && (b = c)) ..."
412 "return foo;" rather than "return(foo);"
416 "if (!foo) ..." rather than "if (foo == FALSE) ..." etc.
420 Do not declare variables using "register". It may be counterproductive
421 with modern compilers, and is deprecated in C++, under which the Perl
422 source is regularly compiled.
426 In-line functions that are in headers that are accessible to XS code
427 need to be able to compile without warnings with commonly used extra
428 compilation flags, such as gcc's C<-Wswitch-default> which warns
429 whenever a switch statement does not have a "default" case. The use of
430 these extra flags is to catch potential problems in legal C code, and
431 is often used by Perl aggregators, such as Linux distributors.
437 If your patch changes code (rather than just changing documentation),
438 you should also include one or more test cases which illustrate the bug
439 you're fixing or validate the new functionality you're adding. In
440 general, you should update an existing test file rather than create a
443 Your test suite additions should generally follow these guidelines
444 (courtesy of Gurusamy Sarathy <gsar@activestate.com>):
450 Know what you're testing. Read the docs, and the source.
454 Tend to fail, not succeed.
458 Interpret results strictly.
462 Use unrelated features (this will flush out bizarre interactions).
466 Use non-standard idioms (otherwise you are not testing TIMTOWTDI).
470 Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT
471 found in t/op/tie.t is much more maintainable, and gives better failure
476 Give meaningful error messages when a test fails.
480 Avoid using qx// and system() unless you are testing for them. If you
481 do use them, make sure that you cover _all_ perl platforms.
485 Unlink any temporary files you create.
489 Promote unforeseen warnings to errors with $SIG{__WARN__}.
493 Be sure to use the libraries and modules shipped with the version being
494 tested, not those that were already installed.
498 Add comments to the code explaining what you are testing for.
502 Make updating the '1..42' string unnecessary. Or make sure that you
507 Test _all_ behaviors of a given operator, library, or function.
509 Test all optional arguments.
511 Test return values in various contexts (boolean, scalar, list, lvalue).
513 Use both global and lexical variables.
515 Don't forget the exceptional, pathological cases.
519 =head2 Patching a core module
521 This works just like patching anything else, with one extra
524 Modules in the F<cpan/> directory of the source tree are maintained
525 outside of the Perl core. When the author updates the module, the
526 updates are simply copied into the core. See that module's
527 documentation or its listing on L<http://search.cpan.org/> for more
528 information on reporting bugs and submitting patches.
530 In most cases, patches to modules in F<cpan/> should be sent upstream
531 and should not be applied to the Perl core individually. If a patch to
532 a file in F<cpan/> absolutely cannot wait for the fix to be made
533 upstream, released to CPAN and copied to blead, you must add (or
534 update) a C<CUSTOMIZED> entry in the F<"Porting/Maintainers.pl"> file
535 to flag that a local modification has been made. See
536 F<"Porting/Maintainers.pl"> for more details.
538 In contrast, modules in the F<dist/> directory are maintained in the
541 =head2 Updating perldelta
543 For changes significant enough to warrant a F<pod/perldelta.pod> entry,
544 the porters will greatly appreciate it if you submit a delta entry
545 along with your actual change. Significant changes include, but are
552 Adding, deprecating, or removing core features
556 Adding, deprecating, removing, or upgrading core or dual-life modules
560 Adding new core tests
564 Fixing security issues and user-visible bugs in the core
568 Changes that might break existing code, either on the perl or C level
572 Significant performance improvements
576 Adding, removing, or significantly changing documentation in the
581 Important platform-specific changes
585 Please make sure you add the perldelta entry to the right section
586 within F<pod/perldelta.pod>. More information on how to write good
587 perldelta entries is available in the C<Style> section of
588 F<Porting/how_to_write_a_perldelta.pod>.
590 =head2 What makes for a good patch?
592 New features and extensions to the language can be contentious. There
593 is no specific set of criteria which determine what features get added,
594 but here are some questions to consider when developing a patch:
596 =head3 Does the concept match the general goals of Perl?
598 Our goals include, but are not limited to:
604 Keep it fast, simple, and useful.
608 Keep features/concepts as orthogonal as possible.
612 No arbitrary limits (platforms, data sizes, cultures).
616 Keep it open and exciting to use/patch/advocate Perl everywhere.
620 Either assimilate new technologies, or build bridges to them.
624 =head3 Where is the implementation?
626 All the talk in the world is useless without an implementation. In
627 almost every case, the person or people who argue for a new feature
628 will be expected to be the ones who implement it. Porters capable of
629 coding new features have their own agendas, and are not available to
630 implement your (possibly good) idea.
632 =head3 Backwards compatibility
634 It's a cardinal sin to break existing Perl programs. New warnings can
635 be contentious--some say that a program that emits warnings is not
636 broken, while others say it is. Adding keywords has the potential to
637 break programs, changing the meaning of existing token sequences or
638 functions might break programs.
640 The Perl 5 core includes mechanisms to help porters make backwards
641 incompatible changes more compatible such as the L<feature> and
642 L<deprecate> modules. Please use them when appropriate.
644 =head3 Could it be a module instead?
646 Perl 5 has extension mechanisms, modules and XS, specifically to avoid
647 the need to keep changing the Perl interpreter. You can write modules
648 that export functions, you can give those functions prototypes so they
649 can be called like built-in functions, you can even write XS code to
650 mess with the runtime data structures of the Perl interpreter if you
651 want to implement really complicated things.
653 Whenever possible, new features should be prototyped in a CPAN module
654 before they will be considered for the core.
656 =head3 Is the feature generic enough?
658 Is this something that only the submitter wants added to the language,
659 or is it broadly useful? Sometimes, instead of adding a feature with a
660 tight focus, the porters might decide to wait until someone implements
661 the more generalized feature.
663 =head3 Does it potentially introduce new bugs?
665 Radical rewrites of large chunks of the Perl interpreter have the
666 potential to introduce new bugs.
668 =head3 How big is it?
670 The smaller and more localized the change, the better. Similarly, a
671 series of small patches is greatly preferred over a single large patch.
673 =head3 Does it preclude other desirable features?
675 A patch is likely to be rejected if it closes off future avenues of
676 development. For instance, a patch that placed a true and final
677 interpretation on prototypes is likely to be rejected because there are
678 still options for the future of prototypes that haven't been addressed.
680 =head3 Is the implementation robust?
682 Good patches (tight code, complete, correct) stand more chance of going
683 in. Sloppy or incorrect patches might be placed on the back burner
684 until the pumpking has time to fix, or might be discarded altogether
685 without further notice.
687 =head3 Is the implementation generic enough to be portable?
689 The worst patches make use of system-specific features. It's highly
690 unlikely that non-portable additions to the Perl language will be
693 =head3 Is the implementation tested?
695 Patches which change behaviour (fixing bugs or introducing new
696 features) must include regression tests to verify that everything works
699 Without tests provided by the original author, how can anyone else
700 changing perl in the future be sure that they haven't unwittingly
701 broken the behaviour the patch implements? And without tests, how can
702 the patch's author be confident that his/her hard work put into the
703 patch won't be accidentally thrown away by someone in the future?
705 =head3 Is there enough documentation?
707 Patches without documentation are probably ill-thought out or
708 incomplete. No features can be added or changed without documentation,
709 so submitting a patch for the appropriate pod docs as well as the
710 source code is important.
712 =head3 Is there another way to do it?
714 Larry said "Although the Perl Slogan is I<There's More Than One Way to
715 Do It>, I hesitate to make 10 ways to do something". This is a tricky
716 heuristic to navigate, though--one man's essential addition is another
717 man's pointless cruft.
719 =head3 Does it create too much work?
721 Work for the pumpking, work for Perl programmers, work for module
722 authors, ... Perl is supposed to be easy.
724 =head3 Patches speak louder than words
726 Working code is always preferred to pie-in-the-sky ideas. A patch to
727 add a feature stands a much higher chance of making it to the language
728 than does a random feature request, no matter how fervently argued the
729 request might be. This ties into "Will it be useful?", as the fact
730 that someone took the time to make the patch demonstrates a strong
731 desire for the feature.
735 The core uses the same testing style as the rest of Perl, a simple
736 "ok/not ok" run through Test::Harness, but there are a few special
739 There are three ways to write a test in the core: L<Test::More>,
740 F<t/test.pl> and ad hoc C<print $test ? "ok 42\n" : "not ok 42\n">.
741 The decision of which to use depends on what part of the test suite
742 you're working on. This is a measure to prevent a high-level failure
743 (such as Config.pm breaking) from causing basic functionality tests to
746 The F<t/test.pl> library provides some of the features of
747 L<Test::More>, but avoids loading most modules and uses as few core
748 features as possible.
750 If you write your own test, use the L<Test Anything
751 Protocol|http://testanything.org>.
755 =item * F<t/base>, F<t/comp> and F<t/opbasic>
757 Since we don't know if C<require> works, or even subroutines, use ad hoc
758 tests for these three. Step carefully to avoid using the feature being
759 tested. Tests in F<t/opbasic>, for instance, have been placed there
760 rather than in F<t/op> because they test functionality which
761 F<t/test.pl> presumes has already been demonstrated to work.
763 =item * F<t/cmd>, F<t/run>, F<t/io> and F<t/op>
765 Now that basic require() and subroutines are tested, you can use the
766 F<t/test.pl> library.
768 You can also use certain libraries like Config conditionally, but be
769 sure to skip the test gracefully if it's not there.
771 =item * Everything else
773 Now that the core of Perl is tested, L<Test::More> can and should be
774 used. You can also use the full suite of core modules in the tests.
778 When you say "make test", Perl uses the F<t/TEST> program to run the
779 test suite (except under Win32 where it uses F<t/harness> instead).
780 All tests are run from the F<t/> directory, B<not> the directory which
781 contains the test. This causes some problems with the tests in
782 F<lib/>, so here's some opportunity for some patching.
784 You must be triply conscious of cross-platform concerns. This usually
785 boils down to using L<File::Spec>, avoiding things like C<fork()>
786 and C<system()> unless absolutely necessary, and not assuming that a
787 given character has a particular ordinal value (code point) or that its
788 UTF-8 representation is composed of particular bytes.
790 There are several functions available to specify characters and code
791 points portably in tests. The always-preloaded functions
792 C<utf8::unicode_to_native()> and its inverse
793 C<utf8::native_to_unicode()> take code points and translate
794 appropriately. The file F<t/charset_tools.pl> has several functions
795 that can be useful. It has versions of the previous two functions
796 that take strings as inputs -- not single numeric code points:
797 C<uni_to_native()> and C<native_to_uni()>. If you must look at the
798 individual bytes comprising a UTF-8 encoded string,
799 C<byte_utf8a_to_utf8n()> takes as input a string of those bytes encoded
800 for an ASCII platform, and returns the equivalent string in the native
801 platform. For example, C<byte_utf8a_to_utf8n("\xC2\xA0")> returns the
802 byte sequence on the current platform that form the UTF-8 for C<U+00A0>,
803 since C<"\xC2\xA0"> are the UTF-8 bytes on an ASCII platform for that
804 code point. This function returns C<"\xC2\xA0"> on an ASCII platform, and
805 C<"\x80\x41"> on an EBCDIC 1047 one.
807 But easiest is, if the character is specifiable as a literal, like
808 C<"A"> or C<"%">, to use that; if not so specificable, you can use use
809 C<\N{}> , if the side effects aren't troublesome. Simply specify all
810 your characters in hex, using C<\N{U+ZZ}> instead of C<\xZZ>. C<\N{}>
811 is the Unicode name, and so it
812 always gives you the Unicode character. C<\N{U+41}> is the character
813 whose Unicode code point is C<0x41>, hence is C<'A'> on all platforms.
814 The side effects are:
820 These select Unicode rules. That means that in double-quotish strings,
821 the string is always converted to UTF-8 to force a Unicode
822 interpretation (you can C<utf8::downgrade()> afterwards to convert back
823 to non-UTF8, if possible). In regular expression patterns, the
824 conversion isn't done, but if the character set modifier would
825 otherwise be C</d>, it is changed to C</u>.
829 If you use the form C<\N{I<character name>}>, the L<charnames> module
830 gets automatically loaded. This may not be suitable for the test level
835 If you are testing locales (see L<perllocale>), there are helper
836 functions in F<t/loc_tools.pl> to enable you to see what locales there
837 are on the current platform.
839 =head2 Special C<make test> targets
841 There are various special make targets that can be used to test Perl
842 slightly differently than the standard "test" target. Not all them are
843 expected to give a 100% success rate. Many of them have several
844 aliases, and many of them are not available on certain operating
851 This runs some basic sanity tests on the source tree and helps catch
852 basic errors before you submit a patch.
856 Run F<miniperl> on F<t/base>, F<t/comp>, F<t/cmd>, F<t/run>, F<t/io>,
857 F<t/op>, F<t/uni> and F<t/mro> tests.
859 =item * test.valgrind check.valgrind
861 (Only in Linux) Run all the tests using the memory leak + naughty
862 memory access tool "valgrind". The log files will be named
863 F<testname.valgrind>.
867 Run the test suite with the F<t/harness> controlling program, instead
868 of F<t/TEST>. F<t/harness> is more sophisticated, and uses the
869 L<Test::Harness> module, thus using this test target supposes that perl
870 mostly works. The main advantage for our purposes is that it prints a
871 detailed summary of failed tests at the end. Also, unlike F<t/TEST>,
872 it doesn't redirect stderr to stdout.
874 Note that under Win32 F<t/harness> is always used instead of F<t/TEST>,
875 so there is no special "test_harness" target.
877 Under Win32's "test" target you may use the TEST_SWITCHES and
878 TEST_FILES environment variables to control the behaviour of
879 F<t/harness>. This means you can say
881 nmake test TEST_FILES="op/*.t"
882 nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t"
884 =item * test-notty test_notty
886 Sets PERL_SKIP_TTY_TEST to true before running normal test.
890 =head2 Parallel tests
892 The core distribution can now run its regression tests in parallel on
893 Unix-like platforms. Instead of running C<make test>, set C<TEST_JOBS>
894 in your environment to the number of tests to run in parallel, and run
895 C<make test_harness>. On a Bourne-like shell, this can be done as
897 TEST_JOBS=3 make test_harness # Run 3 tests in parallel
899 An environment variable is used, rather than parallel make itself,
900 because L<TAP::Harness> needs to be able to schedule individual
901 non-conflicting test scripts itself, and there is no standard interface
902 to C<make> utilities to interact with their job schedulers.
904 Note that currently some test scripts may fail when run in parallel
905 (most notably F<dist/IO/t/io_dir.t>). If necessary, run just the
906 failing scripts again sequentially and see if the failures go away.
908 =head2 Running tests by hand
910 You can run part of the test suite by hand by using one of the
911 following commands from the F<t/> directory:
913 ./perl -I../lib TEST list-of-.t-files
917 ./perl -I../lib harness list-of-.t-files
919 (If you don't specify test scripts, the whole test suite will be run.)
921 =head2 Using F<t/harness> for testing
923 If you use C<harness> for testing, you have several command line
924 options available to you. The arguments are as follows, and are in the
925 order that they must appear if used together.
927 harness -v -torture -re=pattern LIST OF FILES TO TEST
928 harness -v -torture -re LIST OF PATTERNS TO MATCH
930 If C<LIST OF FILES TO TEST> is omitted, the file list is obtained from
931 the manifest. The file list may include shell wildcards which will be
938 Run the tests under verbose mode so you can see what tests were run,
943 Run the torture tests as well as the normal set.
947 Filter the file list so that all the test files run match PATTERN.
948 Note that this form is distinct from the B<-re LIST OF PATTERNS> form
949 below in that it allows the file list to be provided as well.
951 =item * -re LIST OF PATTERNS
953 Filter the file list so that all the test files run match
954 /(LIST|OF|PATTERNS)/. Note that with this form the patterns are joined
955 by '|' and you cannot supply a list of files, instead the test files
956 are obtained from the MANIFEST.
960 You can run an individual test by a command similar to
962 ./perl -I../lib path/to/foo.t
964 except that the harnesses set up some environment variables that may
965 affect the execution of the test:
971 indicates that we're running this test as part of the perl core test
972 suite. This is useful for modules that have a dual life on CPAN.
974 =item * PERL_DESTRUCT_LEVEL=2
976 is set to 2 if it isn't set already (see
977 L<perlhacktips/PERL_DESTRUCT_LEVEL>).
981 (used only by F<t/TEST>) if set, overrides the path to the perl
982 executable that should be used to run the tests (the default being
985 =item * PERL_SKIP_TTY_TEST
987 if set, tells to skip the tests that need a terminal. It's actually
988 set automatically by the Makefile, but can also be forced artificially
989 by running 'make test_notty'.
993 =head3 Other environment variables that may influence tests
997 =item * PERL_TEST_Net_Ping
999 Setting this variable runs all the Net::Ping modules tests, otherwise
1000 some tests that interact with the outside world are skipped. See
1003 =item * PERL_TEST_NOVREXX
1005 Setting this variable skips the vrexx.t tests for OS2::REXX.
1007 =item * PERL_TEST_NUMCONVERTS
1009 This sets a variable in op/numconvert.t.
1011 =item * PERL_TEST_MEMORY
1013 Setting this variable includes the tests in F<t/bigmem/>. This should
1014 be set to the number of gigabytes of memory available for testing, eg.
1015 C<PERL_TEST_MEMORY=4> indicates that tests that require 4GiB of
1016 available memory can be run safely.
1020 See also the documentation for the Test and Test::Harness modules, for
1021 more environment variables that affect testing.
1023 =head2 Performance testing
1025 The file F<t/perf/benchmarks> contains snippets of perl code which are
1026 intended to be benchmarked across a range of perls by the
1027 F<Porting/bench.pl> tool. If you fix or enhance a performance issue, you
1028 may want to add a representative code sample to the file, then run
1029 F<bench.pl> against the previous and current perls to see what difference
1030 it has made, and whether anything else has slowed down as a consequence.
1032 The file F<t/perf/opcount.t> is designed to test whether a particular
1033 code snippet has been compiled into an optree containing specified
1034 numbers of particular op types. This is good for testing whether
1035 optimisations which alter ops, such as converting an C<aelem> op into an
1036 C<aelemfast> op, are really doing that.
1038 The files F<t/perf/speed.t> and F<t/re/speed.t> are designed to test
1039 things that run thousands of times slower if a particular optimisation
1040 is broken (for example, the utf8 length cache on long utf8 strings).
1041 Add a test that will take a fraction of a second normally, and minutes
1042 otherwise, causing the test file to time out on failure.
1044 =head1 MORE READING FOR GUTS HACKERS
1046 To hack on the Perl guts, you'll need to read the following things:
1050 =item * L<perlsource>
1052 An overview of the Perl source tree. This will help you find the files
1055 =item * L<perlinterp>
1057 An overview of the Perl interpreter source code and some details on how
1058 Perl does what it does.
1060 =item * L<perlhacktut>
1062 This document walks through the creation of a small patch to Perl's C
1063 code. If you're just getting started with Perl core hacking, this will
1064 help you understand how it works.
1066 =item * L<perlhacktips>
1068 More details on hacking the Perl core. This document focuses on lower
1069 level details such as how to write tests, compilation issues,
1070 portability, debugging, etc.
1072 If you plan on doing serious C hacking, make sure to read this.
1076 This is of paramount importance, since it's the documentation of what
1077 goes where in the Perl source. Read it over a couple of times and it
1078 might start to make sense - don't worry if it doesn't yet, because the
1079 best way to study it is to read it in conjunction with poking at Perl
1080 source, and we'll do that later on.
1082 Gisle Aas's "illustrated perlguts", also known as I<illguts>, has very
1085 L<http://search.cpan.org/dist/illguts/>
1087 =item * L<perlxstut> and L<perlxs>
1089 A working knowledge of XSUB programming is incredibly useful for core
1090 hacking; XSUBs use techniques drawn from the PP code, the portion of
1091 the guts that actually executes a Perl program. It's a lot gentler to
1092 learn those techniques from simple examples and explanation than from
1097 The documentation for the Perl API explains what some of the internal
1098 functions do, as well as the many macros used in the source.
1100 =item * F<Porting/pumpkin.pod>
1102 This is a collection of words of wisdom for a Perl porter; some of it
1103 is only useful to the pumpkin holder, but most of it applies to anyone
1104 wanting to go about Perl development.
1108 =head1 CPAN TESTERS AND PERL SMOKERS
1110 The CPAN testers ( http://testers.cpan.org/ ) are a group of volunteers
1111 who test CPAN modules on a variety of platforms.
1113 Perl Smokers ( http://www.nntp.perl.org/group/perl.daily-build/ and
1114 http://www.nntp.perl.org/group/perl.daily-build.reports/ )
1115 automatically test Perl source releases on platforms with various
1118 Both efforts welcome volunteers. In order to get involved in smoke
1119 testing of the perl itself visit
1120 L<http://search.cpan.org/dist/Test-Smoke/>. In order to start smoke
1121 testing CPAN modules visit
1122 L<http://search.cpan.org/dist/CPANPLUS-YACSmoke/> or
1123 L<http://search.cpan.org/dist/minismokebox/> or
1124 L<http://search.cpan.org/dist/CPAN-Reporter/>.
1128 If you've read all the documentation in the document and the ones
1129 listed above, you're more than ready to hack on Perl.
1131 Here's some more recommendations
1137 Subscribe to perl5-porters, follow the patches and try and understand
1138 them; don't be afraid to ask if there's a portion you're not clear on -
1139 who knows, you may unearth a bug in the patch...
1143 Do read the README associated with your operating system, e.g.
1144 README.aix on the IBM AIX OS. Don't hesitate to supply patches to that
1145 README if you find anything missing or changed over a new OS release.
1149 Find an area of Perl that seems interesting to you, and see if you can
1150 work out how it works. Scan through the source, and step over it in
1151 the debugger. Play, poke, investigate, fiddle! You'll probably get to
1152 understand not just your chosen area but a much wider range of
1153 F<perl>'s activity as well, and probably sooner than you'd think.
1157 =head2 "The Road goes ever on and on, down from the door where it began."
1159 If you can do these things, you've started on the long road to Perl
1160 porting. Thanks for wanting to help make Perl better - and happy
1163 =head2 Metaphoric Quotations
1165 If you recognized the quote about the Road above, you're in luck.
1167 Most software projects begin each file with a literal description of
1168 each file's purpose. Perl instead begins each with a literary allusion
1169 to that file's purpose.
1171 Like chapters in many books, all top-level Perl source files (along
1172 with a few others here and there) begin with an epigrammatic
1173 inscription that alludes, indirectly and metaphorically, to the
1174 material you're about to read.
1176 Quotations are taken from writings of J.R.R. Tolkien pertaining to his
1177 Legendarium, almost always from I<The Lord of the Rings>. Chapters and
1178 page numbers are given using the following editions:
1184 I<The Hobbit>, by J.R.R. Tolkien. The hardcover, 70th-anniversary
1185 edition of 2007 was used, published in the UK by Harper Collins
1186 Publishers and in the US by the Houghton Mifflin Company.
1190 I<The Lord of the Rings>, by J.R.R. Tolkien. The hardcover,
1191 50th-anniversary edition of 2004 was used, published in the UK by
1192 Harper Collins Publishers and in the US by the Houghton Mifflin
1197 I<The Lays of Beleriand>, by J.R.R. Tolkien and published posthumously
1198 by his son and literary executor, C.J.R. Tolkien, being the 3rd of the
1199 12 volumes in Christopher's mammoth I<History of Middle Earth>. Page
1200 numbers derive from the hardcover edition, first published in 1983 by
1201 George Allen & Unwin; no page numbers changed for the special 3-volume
1202 omnibus edition of 2002 or the various trade-paper editions, all again
1203 now by Harper Collins or Houghton Mifflin.
1207 Other JRRT books fair game for quotes would thus include I<The
1208 Adventures of Tom Bombadil>, I<The Silmarillion>, I<Unfinished Tales>,
1209 and I<The Tale of the Children of Hurin>, all but the first
1210 posthumously assembled by CJRT. But I<The Lord of the Rings> itself is
1211 perfectly fine and probably best to quote from, provided you can find a
1212 suitable quote there.
1214 So if you were to supply a new, complete, top-level source file to add
1215 to Perl, you should conform to this peculiar practice by yourself
1216 selecting an appropriate quotation from Tolkien, retaining the original
1217 spelling and punctuation and using the same format the rest of the
1218 quotes are in. Indirect and oblique is just fine; remember, it's a
1219 metaphor, so being meta is, after all, what it's for.
1223 This document was originally written by Nathan Torkington, and is
1224 maintained by the perl5-porters mailing list.