This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Unused dTHX, even under threads.
[perl5.git] / pod / perlhack.pod
1 =encoding utf8
2
3 =for comment
4 Consistent formatting of this file is achieved with:
5   perl ./Porting/podtidy pod/perlhack.pod
6
7 =head1 NAME
8
9 perlhack - How to hack on Perl
10
11 =head1 DESCRIPTION
12
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
16 philosophy.
17
18 =head1 SUPER QUICK PATCH GUIDE
19
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:
22
23 =over 4
24
25 =item * Check out the source repository
26
27 The perl source is in a git repository.  You can clone the repository
28 with the following command:
29
30   % git clone git://perl5.git.perl.org/perl.git perl
31
32 =item * Ensure you're following the latest advice
33
34 In case the advice in this guide has been updated recently, read the
35 latest version directly from the perl source:
36
37   % perldoc pod/perlhack.pod
38
39 =item * Make your change
40
41 Hack, hack, hack.
42
43 =item * Test your change
44
45 You can run all the tests with the following commands:
46
47   % ./Configure -des -Dusedevel
48   % make test
49
50 Keep hacking until the tests pass.
51
52 =item * Commit your change
53
54 Committing your work will save the change I<on your local system>:
55
56   % git commit -a -m 'Commit message goes here'
57
58 Make sure the commit message describes your change in a single
59 sentence.  For example, "Fixed spelling errors in perlhack.pod".
60
61 =item * Send your change to perlbug
62
63 The next step is to submit your patch to the Perl core ticket system
64 via email.
65
66 If your changes are in a single git commit, run the following commands
67 to generate the patch file and attach it to your bug report:
68
69   % git format-patch -1
70   % ./perl -Ilib utils/perlbug -p 0001-*.patch
71
72 The perlbug program will ask you a few questions about your email
73 address and the patch you're submitting.  Once you've answered them it
74 will submit your patch via email.
75
76 If your changes are in multiple commits, generate a patch file for each
77 one and provide them to perlbug's C<-p> option separated by commas:
78
79   % git format-patch -3
80   % ./perl -Ilib utils/perlbug -p 0001-fix1.patch,0002-fix2.patch,\
81   > 0003-fix3.patch
82
83 When prompted, pick a subject that summarizes your changes.
84
85 =item * Thank you
86
87 The porters appreciate the time you spent helping to make Perl better.
88 Thank you!
89
90 =item * Next time
91
92 The next time you wish to make a patch, you need to start from the
93 latest perl in a pristine state.  Check you don't have any local changes
94 or added files in your perl check-out which you wish to keep, then run
95 these commands:
96
97   % git pull
98   % git reset --hard origin/blead
99   % git clean -dxf
100
101 =back
102
103 =head1 BUG REPORTING
104
105 If you want to report a bug in Perl, you must use the F<perlbug>
106 command line tool.  This tool will ensure that your bug report includes
107 all the relevant system and configuration information.
108
109 To browse existing Perl bugs and patches, you can use the web interface
110 at L<http://rt.perl.org/>.
111
112 Please check the archive of the perl5-porters list (see below) and/or
113 the bug tracking system before submitting a bug report.  Often, you'll
114 find that the bug has been reported already.
115
116 You can log in to the bug tracking system and comment on existing bug
117 reports.  If you have additional information regarding an existing bug,
118 please add it.  This will help the porters fix the bug.
119
120 =head1 PERL 5 PORTERS
121
122 The perl5-porters (p5p) mailing list is where the Perl standard
123 distribution is maintained and developed.  The people who maintain Perl
124 are also referred to as the "Perl 5 Porters", "p5p" or just the
125 "porters".
126
127 A searchable archive of the list is available at
128 L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/>.  There is
129 also another archive at
130 L<http://archive.develooper.com/perl5-porters@perl.org/>.
131
132 =head2 perl-changes mailing list
133
134 The perl5-changes mailing list receives a copy of each patch that gets
135 submitted to the maintenance and development branches of the perl
136 repository.  See L<http://lists.perl.org/list/perl5-changes.html> for
137 subscription and archive information.
138
139 =head2 #p5p on IRC
140
141 Many porters are also active on the L<irc://irc.perl.org/#p5p> channel.
142 Feel free to join the channel and ask questions about hacking on the
143 Perl core.
144
145 =head1 GETTING THE PERL SOURCE
146
147 All of Perl's source code is kept centrally in a Git repository at
148 I<perl5.git.perl.org>.  The repository contains many Perl revisions
149 from Perl 1 onwards and all the revisions from Perforce, the previous
150 version control system.
151
152 For much more detail on using git with the Perl repository, please see
153 L<perlgit>.
154
155 =head2 Read access via Git
156
157 You will need a copy of Git for your computer.  You can fetch a copy of
158 the repository using the git protocol:
159
160   % git clone git://perl5.git.perl.org/perl.git perl
161
162 This clones the repository and makes a local copy in the F<perl>
163 directory.
164
165 If you cannot use the git protocol for firewall reasons, you can also
166 clone via http, though this is much slower:
167
168   % git clone http://perl5.git.perl.org/perl.git perl
169
170 =head2 Read access via the web
171
172 You may access the repository over the web.  This allows you to browse
173 the tree, see recent commits, subscribe to RSS feeds for the changes,
174 search for particular commits and more.  You may access it at
175 L<http://perl5.git.perl.org/perl.git>.  A mirror of the repository is
176 found at L<https://github.com/Perl/perl5>.
177
178 =head2 Read access via rsync
179
180 You can also choose to use rsync to get a copy of the current source
181 tree for the bleadperl branch and all maintenance branches:
182
183   % rsync -avz rsync://perl5.git.perl.org/perl-current .
184   % rsync -avz rsync://perl5.git.perl.org/perl-5.12.x .
185   % rsync -avz rsync://perl5.git.perl.org/perl-5.10.x .
186   % rsync -avz rsync://perl5.git.perl.org/perl-5.8.x .
187   % rsync -avz rsync://perl5.git.perl.org/perl-5.6.x .
188   % rsync -avz rsync://perl5.git.perl.org/perl-5.005xx .
189
190 (Add the C<--delete> option to remove leftover files.)
191
192 To get a full list of the available sync points:
193
194   % rsync perl5.git.perl.org::
195
196 =head2 Write access via git
197
198 If you have a commit bit, please see L<perlgit> for more details on
199 using git.
200
201 =head1 PATCHING PERL
202
203 If you're planning to do more extensive work than a single small fix,
204 we encourage you to read the documentation below.  This will help you
205 focus your work and make your patches easier to incorporate into the
206 Perl source.
207
208 =head2 Submitting patches
209
210 If you have a small patch to submit, please submit it via perlbug.  You
211 can also send email directly to perlbug@perl.org.  Please note that
212 messages sent to perlbug may be held in a moderation queue, so you
213 won't receive a response immediately.
214
215 You'll know your submission has been processed when you receive an
216 email from our ticket tracking system.  This email will give you a
217 ticket number.  Once your patch has made it to the ticket tracking
218 system, it will also be sent to the perl5-porters@perl.org list.
219
220 Patches are reviewed and discussed on the p5p list.  Simple,
221 uncontroversial patches will usually be applied without any discussion.
222 When the patch is applied, the ticket will be updated and you will
223 receive email.  In addition, an email will be sent to the p5p list.
224
225 In other cases, the patch will need more work or discussion.  That will
226 happen on the p5p list.
227
228 You are encouraged to participate in the discussion and advocate for
229 your patch.  Sometimes your patch may get lost in the shuffle.  It's
230 appropriate to send a reminder email to p5p if no action has been taken
231 in a month.  Please remember that the Perl 5 developers are all
232 volunteers, and be polite.
233
234 Changes are always applied directly to the main development branch,
235 called "blead".  Some patches may be backported to a maintenance
236 branch.  If you think your patch is appropriate for the maintenance
237 branch (see L<perlpolicy/MAINTENANCE BRANCHES>), please explain why
238 when you submit it.
239
240 =head2 Getting your patch accepted
241
242 If you are submitting a code patch there are several things that you
243 can do to help the Perl 5 Porters accept your patch.
244
245 =head3 Patch style
246
247 If you used git to check out the Perl source, then using C<git
248 format-patch> will produce a patch in a style suitable for Perl.  The
249 C<format-patch> command produces one patch file for each commit you
250 made.  If you prefer to send a single patch for all commits, you can
251 use C<git diff>.
252
253   % git checkout blead
254   % git pull
255   % git diff blead my-branch-name
256
257 This produces a patch based on the difference between blead and your
258 current branch.  It's important to make sure that blead is up to date
259 before producing the diff, that's why we call C<git pull> first.
260
261 We strongly recommend that you use git if possible.  It will make your
262 life easier, and ours as well.
263
264 However, if you're not using git, you can still produce a suitable
265 patch.  You'll need a pristine copy of the Perl source to diff against.
266 The porters prefer unified diffs.  Using GNU C<diff>, you can produce a
267 diff like this:
268
269   % diff -Npurd perl.pristine perl.mine
270
271 Make sure that you C<make realclean> in your copy of Perl to remove any
272 build artifacts, or you may get a confusing result.
273
274 =head3 Commit message
275
276 As you craft each patch you intend to submit to the Perl core, it's
277 important to write a good commit message.  This is especially important
278 if your submission will consist of a series of commits.
279
280 The first line of the commit message should be a short description
281 without a period.  It should be no longer than the subject line of an
282 email, 50 characters being a good rule of thumb.
283
284 A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will
285 only display the first line (cut off at 50 characters) when presenting
286 commit summaries.
287
288 The commit message should include a description of the problem that the
289 patch corrects or new functionality that the patch adds.
290
291 As a general rule of thumb, your commit message should help a
292 programmer who knows the Perl core quickly understand what you were
293 trying to do, how you were trying to do it, and why the change matters
294 to Perl.
295
296 =over 4
297
298 =item * Why
299
300 Your commit message should describe why the change you are making is
301 important.  When someone looks at your change in six months or six
302 years, your intent should be clear.
303
304 If you're deprecating a feature with the intent of later simplifying
305 another bit of code, say so.  If you're fixing a performance problem or
306 adding a new feature to support some other bit of the core, mention
307 that.
308
309 =item * What
310
311 Your commit message should describe what part of the Perl core you're
312 changing and what you expect your patch to do.
313
314 =item * How
315
316 While it's not necessary for documentation changes, new tests or
317 trivial patches, it's often worth explaining how your change works.
318 Even if it's clear to you today, it may not be clear to a porter next
319 month or next year.
320
321 =back
322
323 A commit message isn't intended to take the place of comments in your
324 code.  Commit messages should describe the change you made, while code
325 comments should describe the current state of the code.
326
327 If you've just implemented a new feature, complete with doc, tests and
328 well-commented code, a brief commit message will often suffice.  If,
329 however, you've just changed a single character deep in the parser or
330 lexer, you might need to write a small novel to ensure that future
331 readers understand what you did and why you did it.
332
333 =head3 Comments, Comments, Comments
334
335 Be sure to adequately comment your code.  While commenting every line
336 is unnecessary, anything that takes advantage of side effects of
337 operators, that creates changes that will be felt outside of the
338 function being patched, or that others may find confusing should be
339 documented.  If you are going to err, it is better to err on the side
340 of adding too many comments than too few.
341
342 The best comments explain I<why> the code does what it does, not I<what
343 it does>.
344
345 =head3 Style
346
347 In general, please follow the particular style of the code you are
348 patching.
349
350 In particular, follow these general guidelines for patching Perl
351 sources:
352
353 =over 4
354
355 =item *
356
357 8-wide tabs (no exceptions!)
358
359 =item *
360
361 4-wide indents for code, 2-wide indents for nested CPP #defines
362
363 =item *
364
365 Try hard not to exceed 79-columns
366
367 =item *
368
369 ANSI C prototypes
370
371 =item *
372
373 Uncuddled elses and "K&R" style for indenting control constructs
374
375 =item *
376
377 No C++ style (//) comments
378
379 =item *
380
381 Mark places that need to be revisited with XXX (and revisit often!)
382
383 =item *
384
385 Opening brace lines up with "if" when conditional spans multiple lines;
386 should be at end-of-line otherwise
387
388 =item *
389
390 In function definitions, name starts in column 0 (return value is on
391 previous line)
392
393 =item *
394
395 Single space after keywords that are followed by parens, no space
396 between function name and following paren
397
398 =item *
399
400 Avoid assignments in conditionals, but if they're unavoidable, use
401 extra paren, e.g. "if (a && (b = c)) ..."
402
403 =item *
404
405 "return foo;" rather than "return(foo);"
406
407 =item *
408
409 "if (!foo) ..." rather than "if (foo == FALSE) ..." etc.
410
411 =item *
412
413 Do not declare variables using "register".  It may be counterproductive
414 with modern compilers, and is deprecated in C++, under which the Perl
415 source is regularly compiled.
416
417 =item *
418
419 In-line functions that are in headers that are accessible to XS code
420 need to be able to compile without warnings with commonly used extra
421 compilation flags, such as gcc's C<-Wswitch-default> which warns
422 whenever a switch statement does not have a "default" case.  The use of
423 these extra flags is to catch potential problems in legal C code, and
424 is often used by Perl aggregators, such as Linux distributors.
425
426 =back
427
428 =head3 Test suite
429
430 If your patch changes code (rather than just changing documentation),
431 you should also include one or more test cases which illustrate the bug
432 you're fixing or validate the new functionality you're adding.  In
433 general, you should update an existing test file rather than create a
434 new one.
435
436 Your test suite additions should generally follow these guidelines
437 (courtesy of Gurusamy Sarathy <gsar@activestate.com>):
438
439 =over 4
440
441 =item *
442
443 Know what you're testing.  Read the docs, and the source.
444
445 =item *
446
447 Tend to fail, not succeed.
448
449 =item *
450
451 Interpret results strictly.
452
453 =item *
454
455 Use unrelated features (this will flush out bizarre interactions).
456
457 =item *
458
459 Use non-standard idioms (otherwise you are not testing TIMTOWTDI).
460
461 =item *
462
463 Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT
464 found in t/op/tie.t is much more maintainable, and gives better failure
465 reports).
466
467 =item *
468
469 Give meaningful error messages when a test fails.
470
471 =item *
472
473 Avoid using qx// and system() unless you are testing for them.  If you
474 do use them, make sure that you cover _all_ perl platforms.
475
476 =item *
477
478 Unlink any temporary files you create.
479
480 =item *
481
482 Promote unforeseen warnings to errors with $SIG{__WARN__}.
483
484 =item *
485
486 Be sure to use the libraries and modules shipped with the version being
487 tested, not those that were already installed.
488
489 =item *
490
491 Add comments to the code explaining what you are testing for.
492
493 =item *
494
495 Make updating the '1..42' string unnecessary.  Or make sure that you
496 update it.
497
498 =item *
499
500 Test _all_ behaviors of a given operator, library, or function.
501
502 Test all optional arguments.
503
504 Test return values in various contexts (boolean, scalar, list, lvalue).
505
506 Use both global and lexical variables.
507
508 Don't forget the exceptional, pathological cases.
509
510 =back
511
512 =head2 Patching a core module
513
514 This works just like patching anything else, with one extra
515 consideration.
516
517 Modules in the F<cpan/> directory of the source tree are maintained
518 outside of the Perl core.  When the author updates the module, the
519 updates are simply copied into the core.  See that module's
520 documentation or its listing on L<http://search.cpan.org/> for more
521 information on reporting bugs and submitting patches.
522
523 In most cases, patches to modules in F<cpan/> should be sent upstream
524 and should not be applied to the Perl core individually.  If a patch to
525 a file in F<cpan/> absolutely cannot wait for the fix to be made
526 upstream, released to CPAN and copied to blead, you must add (or
527 update) a C<CUSTOMIZED> entry in the F<"Porting/Maintainers.pl"> file
528 to flag that a local modification has been made.  See
529 F<"Porting/Maintainers.pl"> for more details.
530
531 In contrast, modules in the F<dist/> directory are maintained in the
532 core.
533
534 =head2 Updating perldelta
535
536 For changes significant enough to warrant a F<pod/perldelta.pod> entry,
537 the porters will greatly appreciate it if you submit a delta entry
538 along with your actual change.  Significant changes include, but are
539 not limited to:
540
541 =over 4
542
543 =item *
544
545 Adding, deprecating, or removing core features
546
547 =item *
548
549 Adding, deprecating, removing, or upgrading core or dual-life modules
550
551 =item *
552
553 Adding new core tests
554
555 =item *
556
557 Fixing security issues and user-visible bugs in the core
558
559 =item *
560
561 Changes that might break existing code, either on the perl or C level
562
563 =item *
564
565 Significant performance improvements
566
567 =item *
568
569 Adding, removing, or significantly changing documentation in the
570 F<pod/> directory
571
572 =item *
573
574 Important platform-specific changes
575
576 =back
577
578 Please make sure you add the perldelta entry to the right section
579 within F<pod/perldelta.pod>.  More information on how to write good
580 perldelta entries is available in the C<Style> section of
581 F<Porting/how_to_write_a_perldelta.pod>.
582
583 =head2 What makes for a good patch?
584
585 New features and extensions to the language can be contentious.  There
586 is no specific set of criteria which determine what features get added,
587 but here are some questions to consider when developing a patch:
588
589 =head3 Does the concept match the general goals of Perl?
590
591 Our goals include, but are not limited to:
592
593 =over 4
594
595 =item 1.
596
597 Keep it fast, simple, and useful.
598
599 =item 2.
600
601 Keep features/concepts as orthogonal as possible.
602
603 =item 3.
604
605 No arbitrary limits (platforms, data sizes, cultures).
606
607 =item 4.
608
609 Keep it open and exciting to use/patch/advocate Perl everywhere.
610
611 =item 5.
612
613 Either assimilate new technologies, or build bridges to them.
614
615 =back
616
617 =head3 Where is the implementation?
618
619 All the talk in the world is useless without an implementation.  In
620 almost every case, the person or people who argue for a new feature
621 will be expected to be the ones who implement it.  Porters capable of
622 coding new features have their own agendas, and are not available to
623 implement your (possibly good) idea.
624
625 =head3 Backwards compatibility
626
627 It's a cardinal sin to break existing Perl programs.  New warnings can
628 be contentious--some say that a program that emits warnings is not
629 broken, while others say it is.  Adding keywords has the potential to
630 break programs, changing the meaning of existing token sequences or
631 functions might break programs.
632
633 The Perl 5 core includes mechanisms to help porters make backwards
634 incompatible changes more compatible such as the L<feature> and
635 L<deprecate> modules.  Please use them when appropriate.
636
637 =head3 Could it be a module instead?
638
639 Perl 5 has extension mechanisms, modules and XS, specifically to avoid
640 the need to keep changing the Perl interpreter.  You can write modules
641 that export functions, you can give those functions prototypes so they
642 can be called like built-in functions, you can even write XS code to
643 mess with the runtime data structures of the Perl interpreter if you
644 want to implement really complicated things.
645
646 Whenever possible, new features should be prototyped in a CPAN module
647 before they will be considered for the core.
648
649 =head3 Is the feature generic enough?
650
651 Is this something that only the submitter wants added to the language,
652 or is it broadly useful?  Sometimes, instead of adding a feature with a
653 tight focus, the porters might decide to wait until someone implements
654 the more generalized feature.
655
656 =head3 Does it potentially introduce new bugs?
657
658 Radical rewrites of large chunks of the Perl interpreter have the
659 potential to introduce new bugs.
660
661 =head3 How big is it?
662
663 The smaller and more localized the change, the better.  Similarly, a
664 series of small patches is greatly preferred over a single large patch.
665
666 =head3 Does it preclude other desirable features?
667
668 A patch is likely to be rejected if it closes off future avenues of
669 development.  For instance, a patch that placed a true and final
670 interpretation on prototypes is likely to be rejected because there are
671 still options for the future of prototypes that haven't been addressed.
672
673 =head3 Is the implementation robust?
674
675 Good patches (tight code, complete, correct) stand more chance of going
676 in.  Sloppy or incorrect patches might be placed on the back burner
677 until the pumpking has time to fix, or might be discarded altogether
678 without further notice.
679
680 =head3 Is the implementation generic enough to be portable?
681
682 The worst patches make use of system-specific features.  It's highly
683 unlikely that non-portable additions to the Perl language will be
684 accepted.
685
686 =head3 Is the implementation tested?
687
688 Patches which change behaviour (fixing bugs or introducing new
689 features) must include regression tests to verify that everything works
690 as expected.
691
692 Without tests provided by the original author, how can anyone else
693 changing perl in the future be sure that they haven't unwittingly
694 broken the behaviour the patch implements? And without tests, how can
695 the patch's author be confident that his/her hard work put into the
696 patch won't be accidentally thrown away by someone in the future?
697
698 =head3 Is there enough documentation?
699
700 Patches without documentation are probably ill-thought out or
701 incomplete.  No features can be added or changed without documentation,
702 so submitting a patch for the appropriate pod docs as well as the
703 source code is important.
704
705 =head3 Is there another way to do it?
706
707 Larry said "Although the Perl Slogan is I<There's More Than One Way to
708 Do It>, I hesitate to make 10 ways to do something".  This is a tricky
709 heuristic to navigate, though--one man's essential addition is another
710 man's pointless cruft.
711
712 =head3 Does it create too much work?
713
714 Work for the pumpking, work for Perl programmers, work for module
715 authors, ... Perl is supposed to be easy.
716
717 =head3 Patches speak louder than words
718
719 Working code is always preferred to pie-in-the-sky ideas.  A patch to
720 add a feature stands a much higher chance of making it to the language
721 than does a random feature request, no matter how fervently argued the
722 request might be.  This ties into "Will it be useful?", as the fact
723 that someone took the time to make the patch demonstrates a strong
724 desire for the feature.
725
726 =head1 TESTING
727
728 The core uses the same testing style as the rest of Perl, a simple
729 "ok/not ok" run through Test::Harness, but there are a few special
730 considerations.
731
732 There are three ways to write a test in the core: L<Test::More>,
733 F<t/test.pl> and ad hoc C<print $test ? "ok 42\n" : "not ok 42\n">.
734 The decision of which to use depends on what part of the test suite
735 you're working on.  This is a measure to prevent a high-level failure
736 (such as Config.pm breaking) from causing basic functionality tests to
737 fail.
738
739 The F<t/test.pl> library provides some of the features of
740 L<Test::More>, but avoids loading most modules and uses as few core
741 features as possible.
742
743 If you write your own test, use the L<Test Anything
744 Protocol|http://testanything.org>.
745
746 =over 4
747
748 =item * F<t/base>, F<t/comp> and F<t/opbasic>
749
750 Since we don't know if require works, or even subroutines, use ad hoc
751 tests for these three.  Step carefully to avoid using the feature being
752 tested.  Tests in F<t/opbasic>, for instance, have been placed there
753 rather than in F<t/op> because they test functionality which
754 F<t/test.pl> presumes has already been demonstrated to work.
755
756 =item * F<t/cmd>, F<t/run>, F<t/io> and F<t/op>
757
758 Now that basic require() and subroutines are tested, you can use the
759 F<t/test.pl> library.
760
761 You can also use certain libraries like Config conditionally, but be
762 sure to skip the test gracefully if it's not there.
763
764 =item * Everything else
765
766 Now that the core of Perl is tested, L<Test::More> can and should be
767 used.  You can also use the full suite of core modules in the tests.
768
769 =back
770
771 When you say "make test", Perl uses the F<t/TEST> program to run the
772 test suite (except under Win32 where it uses F<t/harness> instead).
773 All tests are run from the F<t/> directory, B<not> the directory which
774 contains the test.  This causes some problems with the tests in
775 F<lib/>, so here's some opportunity for some patching.
776
777 You must be triply conscious of cross-platform concerns.  This usually
778 boils down to using L<File::Spec> and avoiding things like C<fork()>
779 and C<system()> unless absolutely necessary.
780
781 =head2 Special C<make test> targets
782
783 There are various special make targets that can be used to test Perl
784 slightly differently than the standard "test" target.  Not all them are
785 expected to give a 100% success rate.  Many of them have several
786 aliases, and many of them are not available on certain operating
787 systems.
788
789 =over 4
790
791 =item * test_porting
792
793 This runs some basic sanity tests on the source tree and helps catch
794 basic errors before you submit a patch.
795
796 =item * minitest
797
798 Run F<miniperl> on F<t/base>, F<t/comp>, F<t/cmd>, F<t/run>, F<t/io>,
799 F<t/op>, F<t/uni> and F<t/mro> tests.
800
801 =item * test.valgrind check.valgrind
802
803 (Only in Linux) Run all the tests using the memory leak + naughty
804 memory access tool "valgrind".  The log files will be named
805 F<testname.valgrind>.
806
807 =item * test_harness
808
809 Run the test suite with the F<t/harness> controlling program, instead
810 of F<t/TEST>.  F<t/harness> is more sophisticated, and uses the
811 L<Test::Harness> module, thus using this test target supposes that perl
812 mostly works.  The main advantage for our purposes is that it prints a
813 detailed summary of failed tests at the end.  Also, unlike F<t/TEST>,
814 it doesn't redirect stderr to stdout.
815
816 Note that under Win32 F<t/harness> is always used instead of F<t/TEST>,
817 so there is no special "test_harness" target.
818
819 Under Win32's "test" target you may use the TEST_SWITCHES and
820 TEST_FILES environment variables to control the behaviour of
821 F<t/harness>.  This means you can say
822
823     nmake test TEST_FILES="op/*.t"
824     nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t"
825
826 =item * test-notty test_notty
827
828 Sets PERL_SKIP_TTY_TEST to true before running normal test.
829
830 =back
831
832 =head2 Parallel tests
833
834 The core distribution can now run its regression tests in parallel on
835 Unix-like platforms.  Instead of running C<make test>, set C<TEST_JOBS>
836 in your environment to the number of tests to run in parallel, and run
837 C<make test_harness>.  On a Bourne-like shell, this can be done as
838
839     TEST_JOBS=3 make test_harness  # Run 3 tests in parallel
840
841 An environment variable is used, rather than parallel make itself,
842 because L<TAP::Harness> needs to be able to schedule individual
843 non-conflicting test scripts itself, and there is no standard interface
844 to C<make> utilities to interact with their job schedulers.
845
846 Note that currently some test scripts may fail when run in parallel
847 (most notably F<ext/IO/t/io_dir.t>).  If necessary, run just the
848 failing scripts again sequentially and see if the failures go away.
849
850 =head2 Running tests by hand
851
852 You can run part of the test suite by hand by using one of the
853 following commands from the F<t/> directory:
854
855     ./perl -I../lib TEST list-of-.t-files
856
857 or
858
859     ./perl -I../lib harness list-of-.t-files
860
861 (If you don't specify test scripts, the whole test suite will be run.)
862
863 =head2 Using F<t/harness> for testing
864
865 If you use C<harness> for testing, you have several command line
866 options available to you.  The arguments are as follows, and are in the
867 order that they must appear if used together.
868
869     harness -v -torture -re=pattern LIST OF FILES TO TEST
870     harness -v -torture -re LIST OF PATTERNS TO MATCH
871
872 If C<LIST OF FILES TO TEST> is omitted, the file list is obtained from
873 the manifest.  The file list may include shell wildcards which will be
874 expanded out.
875
876 =over 4
877
878 =item * -v
879
880 Run the tests under verbose mode so you can see what tests were run,
881 and debug output.
882
883 =item * -torture
884
885 Run the torture tests as well as the normal set.
886
887 =item * -re=PATTERN
888
889 Filter the file list so that all the test files run match PATTERN.
890 Note that this form is distinct from the B<-re LIST OF PATTERNS> form
891 below in that it allows the file list to be provided as well.
892
893 =item * -re LIST OF PATTERNS
894
895 Filter the file list so that all the test files run match
896 /(LIST|OF|PATTERNS)/.  Note that with this form the patterns are joined
897 by '|' and you cannot supply a list of files, instead the test files
898 are obtained from the MANIFEST.
899
900 =back
901
902 You can run an individual test by a command similar to
903
904     ./perl -I../lib path/to/foo.t
905
906 except that the harnesses set up some environment variables that may
907 affect the execution of the test:
908
909 =over 4
910
911 =item * PERL_CORE=1
912
913 indicates that we're running this test as part of the perl core test
914 suite.  This is useful for modules that have a dual life on CPAN.
915
916 =item * PERL_DESTRUCT_LEVEL=2
917
918 is set to 2 if it isn't set already (see
919 L<perlhacktips/PERL_DESTRUCT_LEVEL>).
920
921 =item * PERL
922
923 (used only by F<t/TEST>) if set, overrides the path to the perl
924 executable that should be used to run the tests (the default being
925 F<./perl>).
926
927 =item * PERL_SKIP_TTY_TEST
928
929 if set, tells to skip the tests that need a terminal.  It's actually
930 set automatically by the Makefile, but can also be forced artificially
931 by running 'make test_notty'.
932
933 =back
934
935 =head3 Other environment variables that may influence tests
936
937 =over 4
938
939 =item * PERL_TEST_Net_Ping
940
941 Setting this variable runs all the Net::Ping modules tests, otherwise
942 some tests that interact with the outside world are skipped.  See
943 L<perl58delta>.
944
945 =item * PERL_TEST_NOVREXX
946
947 Setting this variable skips the vrexx.t tests for OS2::REXX.
948
949 =item * PERL_TEST_NUMCONVERTS
950
951 This sets a variable in op/numconvert.t.
952
953 =item * PERL_TEST_MEMORY
954
955 Setting this variable includes the tests in F<t/bigmem/>.  This should
956 be set to the number of gigabytes of memory available for testing, eg.
957 C<PERL_TEST_MEMORY=4> indicates that tests that require 4GiB of
958 available memory can be run safely.
959
960 =back
961
962 See also the documentation for the Test and Test::Harness modules, for
963 more environment variables that affect testing.
964
965 =head1 MORE READING FOR GUTS HACKERS
966
967 To hack on the Perl guts, you'll need to read the following things:
968
969 =over 4
970
971 =item * L<perlsource>
972
973 An overview of the Perl source tree.  This will help you find the files
974 you're looking for.
975
976 =item * L<perlinterp>
977
978 An overview of the Perl interpreter source code and some details on how
979 Perl does what it does.
980
981 =item * L<perlhacktut>
982
983 This document walks through the creation of a small patch to Perl's C
984 code.  If you're just getting started with Perl core hacking, this will
985 help you understand how it works.
986
987 =item * L<perlhacktips>
988
989 More details on hacking the Perl core.  This document focuses on lower
990 level details such as how to write tests, compilation issues,
991 portability, debugging, etc.
992
993 If you plan on doing serious C hacking, make sure to read this.
994
995 =item * L<perlguts>
996
997 This is of paramount importance, since it's the documentation of what
998 goes where in the Perl source.  Read it over a couple of times and it
999 might start to make sense - don't worry if it doesn't yet, because the
1000 best way to study it is to read it in conjunction with poking at Perl
1001 source, and we'll do that later on.
1002
1003 Gisle Aas's "illustrated perlguts", also known as I<illguts>, has very
1004 helpful pictures:
1005
1006 L<http://search.cpan.org/dist/illguts/>
1007
1008 =item * L<perlxstut> and L<perlxs>
1009
1010 A working knowledge of XSUB programming is incredibly useful for core
1011 hacking; XSUBs use techniques drawn from the PP code, the portion of
1012 the guts that actually executes a Perl program.  It's a lot gentler to
1013 learn those techniques from simple examples and explanation than from
1014 the core itself.
1015
1016 =item * L<perlapi>
1017
1018 The documentation for the Perl API explains what some of the internal
1019 functions do, as well as the many macros used in the source.
1020
1021 =item * F<Porting/pumpkin.pod>
1022
1023 This is a collection of words of wisdom for a Perl porter; some of it
1024 is only useful to the pumpkin holder, but most of it applies to anyone
1025 wanting to go about Perl development.
1026
1027 =back
1028
1029 =head1 CPAN TESTERS AND PERL SMOKERS
1030
1031 The CPAN testers ( http://testers.cpan.org/ ) are a group of volunteers
1032 who test CPAN modules on a variety of platforms.
1033
1034 Perl Smokers ( http://www.nntp.perl.org/group/perl.daily-build/ and
1035 http://www.nntp.perl.org/group/perl.daily-build.reports/ )
1036 automatically test Perl source releases on platforms with various
1037 configurations.
1038
1039 Both efforts welcome volunteers.  In order to get involved in smoke
1040 testing of the perl itself visit
1041 L<http://search.cpan.org/dist/Test-Smoke/>.  In order to start smoke
1042 testing CPAN modules visit
1043 L<http://search.cpan.org/dist/CPANPLUS-YACSmoke/> or
1044 L<http://search.cpan.org/dist/minismokebox/> or
1045 L<http://search.cpan.org/dist/CPAN-Reporter/>.
1046
1047 =head1 WHAT NEXT?
1048
1049 If you've read all the documentation in the document and the ones
1050 listed above, you're more than ready to hack on Perl.
1051
1052 Here's some more recommendations
1053
1054 =over 4
1055
1056 =item *
1057
1058 Subscribe to perl5-porters, follow the patches and try and understand
1059 them; don't be afraid to ask if there's a portion you're not clear on -
1060 who knows, you may unearth a bug in the patch...
1061
1062 =item *
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 that
1066 README if you find anything missing or changed over a new OS release.
1067
1068 =item *
1069
1070 Find an area of Perl that seems interesting to you, and see if you can
1071 work out how it works.  Scan through the source, and step over it in
1072 the debugger.  Play, poke, investigate, fiddle! You'll probably get to
1073 understand not just your chosen area but a much wider range of
1074 F<perl>'s activity as well, and probably sooner than you'd think.
1075
1076 =back
1077
1078 =head2 "The Road goes ever on and on, down from the door where it began."
1079
1080 If you can do these things, you've started on the long road to Perl
1081 porting.  Thanks for wanting to help make Perl better - and happy
1082 hacking!
1083
1084 =head2 Metaphoric Quotations
1085
1086 If you recognized the quote about the Road above, you're in luck.
1087
1088 Most software projects begin each file with a literal description of
1089 each file's purpose.  Perl instead begins each with a literary allusion
1090 to that file's purpose.
1091
1092 Like chapters in many books, all top-level Perl source files (along
1093 with a few others here and there) begin with an epigrammatic
1094 inscription that alludes, indirectly and metaphorically, to the
1095 material you're about to read.
1096
1097 Quotations are taken from writings of J.R.R. Tolkien pertaining to his
1098 Legendarium, almost always from I<The Lord of the Rings>.  Chapters and
1099 page numbers are given using the following editions:
1100
1101 =over 4
1102
1103 =item *
1104
1105 I<The Hobbit>, by J.R.R. Tolkien.  The hardcover, 70th-anniversary
1106 edition of 2007 was used, published in the UK by Harper Collins
1107 Publishers and in the US by the Houghton Mifflin Company.
1108
1109 =item *
1110
1111 I<The Lord of the Rings>, by J.R.R. Tolkien.  The hardcover,
1112 50th-anniversary edition of 2004 was used, published in the UK by
1113 Harper Collins Publishers and in the US by the Houghton Mifflin
1114 Company.
1115
1116 =item *
1117
1118 I<The Lays of Beleriand>, by J.R.R. Tolkien and published posthumously
1119 by his son and literary executor, C.J.R. Tolkien, being the 3rd of the
1120 12 volumes in Christopher's mammoth I<History of Middle Earth>.  Page
1121 numbers derive from the hardcover edition, first published in 1983 by
1122 George Allen & Unwin; no page numbers changed for the special 3-volume
1123 omnibus edition of 2002 or the various trade-paper editions, all again
1124 now by Harper Collins or Houghton Mifflin.
1125
1126 =back
1127
1128 Other JRRT books fair game for quotes would thus include I<The
1129 Adventures of Tom Bombadil>, I<The Silmarillion>, I<Unfinished Tales>,
1130 and I<The Tale of the Children of Hurin>, all but the first
1131 posthumously assembled by CJRT.  But I<The Lord of the Rings> itself is
1132 perfectly fine and probably best to quote from, provided you can find a
1133 suitable quote there.
1134
1135 So if you were to supply a new, complete, top-level source file to add
1136 to Perl, you should conform to this peculiar practice by yourself
1137 selecting an appropriate quotation from Tolkien, retaining the original
1138 spelling and punctuation and using the same format the rest of the
1139 quotes are in.  Indirect and oblique is just fine; remember, it's a
1140 metaphor, so being meta is, after all, what it's for.
1141
1142 =head1 AUTHOR
1143
1144 This document was originally written by Nathan Torkington, and is
1145 maintained by the perl5-porters mailing list.
1146