This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Reapply "docs: clarify effect of $^H, %^H, ${^WARNING_BITS}"
[perl5.git] / pod / perlhack.pod
CommitLineData
04c692a8 1=encoding utf8
35c336e6 2
04c692a8
DR
3=for comment
4Consistent formatting of this file is achieved with:
5 perl ./Porting/podtidy pod/perlhack.pod
35c336e6 6
04c692a8 7=head1 NAME
35c336e6 8
04c692a8 9perlhack - How to hack on Perl
35c336e6 10
04c692a8 11=head1 DESCRIPTION
35c336e6 12
531e2078 13This document explains how Perl development works. It includes details
617d9ec4 14about the Perl 5 Porters email list, the Perl repository, the Perl
04c692a8
DR
15bug tracker, patch guidelines, and commentary on Perl development
16philosophy.
f7e1e956 17
04c692a8 18=head1 SUPER QUICK PATCH GUIDE
f7e1e956 19
04c692a8
DR
20If you just want to submit a single small patch like a pod fix, a test
21for a bug, comment fixes, etc., it's easy! Here's how:
f7e1e956 22
04c692a8 23=over 4
e018f8be 24
04c692a8 25=item * Check out the source repository
e018f8be 26
531e2078 27The perl source is in a git repository. You can clone the repository
04c692a8 28with the following command:
e018f8be 29
47ef154c 30 % git clone https://github.com/Perl/perl5.git perl
e018f8be 31
69434957
S
32=item * Ensure you're following the latest advice
33
34In case the advice in this guide has been updated recently, read the
35latest version directly from the perl source:
36
37 % perldoc pod/perlhack.pod
38
617d9ec4
DB
39=item * Create a branch for your change
40
41Create a branch based on blead to commit your change to, which will
42later be used to send it to the Perl issue tracker.
43
44 % git checkout -b mychange
45
04c692a8 46=item * Make your change
e018f8be 47
eb9df707
KW
48Hack, hack, hack. Keep in mind that Perl runs on many different
49platforms, with different operating systems that have different
50capabilities, different filesystem organizations, and even different
51character sets. L<perlhacktips> gives advice on this.
7205a85d 52
04c692a8 53=item * Test your change
e018f8be 54
04c692a8 55You can run all the tests with the following commands:
b26492ee 56
04c692a8
DR
57 % ./Configure -des -Dusedevel
58 % make test
7205a85d 59
04c692a8 60Keep hacking until the tests pass.
b26492ee 61
04c692a8 62=item * Commit your change
e018f8be 63
b6538e4f 64Committing your work will save the change I<on your local system>:
7205a85d 65
04c692a8 66 % git commit -a -m 'Commit message goes here'
e018f8be 67
04c692a8 68Make sure the commit message describes your change in a single
531e2078 69sentence. For example, "Fixed spelling errors in perlhack.pod".
e018f8be 70
617d9ec4 71=item * Send your change to the Perl issue tracker
7a834142 72
617d9ec4 73The next step is to submit your patch to the Perl core ticket system.
7a834142 74
617d9ec4
DB
75Create a GitHub fork of the perl5 repository and add it as a remote,
76if you haven't already, as described in the GitHub documentation at
77L<https://help.github.com/en/articles/working-with-forks>.
e018f8be 78
617d9ec4 79 % git remote add fork git@github.com:MyUser/perl5.git
e018f8be 80
b998bd1a 81For more information, see L<"Connecting to GitHub with SSH"|https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh>.
82
83If you'd rather use an HTTPS URL for your C<git push> see L<"Cloning with
84HTTPS URLs"|https://docs.github.com/en/free-pro-team@latest/github/using-git/which-remote-url-should-i-use#cloning-with-https-urls>.
85
86 % git remote add fork https://github.com/MyUser/perl5.git
87
617d9ec4 88Then, push your new branch to your fork.
e018f8be 89
617d9ec4 90 % git push -u fork mychange
2d1c9392 91
617d9ec4
DB
92Finally, create a Pull Request on GitHub from your branch to blead as
93described in the GitHub documentation at
94L<https://help.github.com/en/articles/creating-a-pull-request-from-a-fork>.
2d1c9392 95
04c692a8 96=item * Thank you
e018f8be 97
04c692a8
DR
98The porters appreciate the time you spent helping to make Perl better.
99Thank you!
e018f8be 100
bb288857
S
101=item * Acknowledgement
102
103All contributors are credited (by name and email address) in the
6cb72a3d
S
104AUTHORS file, which is part of the perl distribution, as well as the
105Git commit history.
bb288857
S
106
107If you don’t want to be included in the AUTHORS file, just let us
108know. Otherwise we will take your submission of a patch as permission
109to credit you in the AUTHORS file.
110
e99cf3f0
S
111=item * Next time
112
113The next time you wish to make a patch, you need to start from the
30454452 114latest perl in a pristine state. Check you don't have any local changes
e99cf3f0
S
115or added files in your perl check-out which you wish to keep, then run
116these commands:
117
617d9ec4 118 % git checkout blead
e99cf3f0
S
119 % git pull
120 % git reset --hard origin/blead
121 % git clean -dxf
122
cce04beb 123=back
e018f8be 124
04c692a8 125=head1 BUG REPORTING
cc0710ff 126
8166b4e0
DB
127If you want to report a bug in Perl, or browse existing Perl bugs and
128patches, use the GitHub issue tracker at
129L<https://github.com/perl/perl5/issues>.
244d9cb7 130
04c692a8 131Please check the archive of the perl5-porters list (see below) and/or
531e2078 132the bug tracking system before submitting a bug report. Often, you'll
04c692a8 133find that the bug has been reported already.
244d9cb7 134
04c692a8 135You can log in to the bug tracking system and comment on existing bug
531e2078
FC
136reports. If you have additional information regarding an existing bug,
137please add it. This will help the porters fix the bug.
7205a85d 138
04c692a8 139=head1 PERL 5 PORTERS
7205a85d 140
04c692a8 141The perl5-porters (p5p) mailing list is where the Perl standard
531e2078 142distribution is maintained and developed. The people who maintain Perl
9e6670f3
DR
143are also referred to as the "Perl 5 Porters", "p5p" or just the
144"porters".
a75f557c 145
04c692a8 146A searchable archive of the list is available at
71c89d21
MM
147L<https://markmail.org/search/?q=perl5-porters>. There is also an archive at
148L<https://archive.develooper.com/perl5-porters@perl.org/>.
7205a85d 149
04c692a8 150=head2 perl-changes mailing list
7205a85d 151
04c692a8
DR
152The perl5-changes mailing list receives a copy of each patch that gets
153submitted to the maintenance and development branches of the perl
fdee78a1 154repository. See L<https://lists.perl.org/list/perl5-changes.html> for
04c692a8 155subscription and archive information.
244d9cb7 156
37bf3a91
DR
157=head2 #p5p on IRC
158
159Many porters are also active on the L<irc://irc.perl.org/#p5p> channel.
160Feel free to join the channel and ask questions about hacking on the
161Perl core.
162
04c692a8 163=head1 GETTING THE PERL SOURCE
244d9cb7 164
04c692a8 165All of Perl's source code is kept centrally in a Git repository at
47ef154c 166I<github.com>. The repository contains many Perl revisions
a44b8c28 167from Perl 1 onwards and all the revisions from Perforce, the previous
04c692a8 168version control system.
244d9cb7 169
04c692a8
DR
170For much more detail on using git with the Perl repository, please see
171L<perlgit>.
244d9cb7 172
04c692a8 173=head2 Read access via Git
244d9cb7 174
531e2078 175You will need a copy of Git for your computer. You can fetch a copy of
04c692a8 176the repository using the git protocol:
244d9cb7 177
a85e04e2 178 % git clone git@github.com:Perl/perl5.git perl
244d9cb7 179
04c692a8
DR
180This clones the repository and makes a local copy in the F<perl>
181directory.
7205a85d 182
04c692a8 183If you cannot use the git protocol for firewall reasons, you can also
47ef154c 184clone via http:
7205a85d 185
47ef154c 186 % git clone https://github.com/Perl/perl5.git perl
7205a85d 187
04c692a8 188=head2 Read access via the web
7205a85d 189
531e2078 190You may access the repository over the web. This allows you to browse
47ef154c 191the tree, see recent commits, subscribe to repository notifications,
531e2078 192search for particular commits and more. You may access it at
47ef154c 193L<https://github.com/Perl/perl5>.
7205a85d 194
04c692a8 195=head2 Write access via git
7205a85d 196
04c692a8
DR
197If you have a commit bit, please see L<perlgit> for more details on
198using git.
7205a85d 199
04c692a8 200=head1 PATCHING PERL
7205a85d 201
04c692a8 202If you're planning to do more extensive work than a single small fix,
531e2078 203we encourage you to read the documentation below. This will help you
04c692a8
DR
204focus your work and make your patches easier to incorporate into the
205Perl source.
244d9cb7 206
04c692a8 207=head2 Submitting patches
244d9cb7 208
617d9ec4
DB
209If you have a small patch to submit, please submit it via the GitHub
210Pull Request workflow. You may also send patches to the p5p list.
244d9cb7 211
617d9ec4 212Patches are reviewed and discussed on GitHub or the p5p list. Simple,
04c692a8
DR
213uncontroversial patches will usually be applied without any discussion.
214When the patch is applied, the ticket will be updated and you will
617d9ec4 215receive email.
244d9cb7 216
617d9ec4 217In other cases, the patch will need more work or discussion.
04c692a8 218You are encouraged to participate in the discussion and advocate for
531e2078 219your patch. Sometimes your patch may get lost in the shuffle. It's
04c692a8 220appropriate to send a reminder email to p5p if no action has been taken
531e2078 221in a month. Please remember that the Perl 5 developers are all
04c692a8 222volunteers, and be polite.
244d9cb7 223
04c692a8 224Changes are always applied directly to the main development branch,
a44b8c28 225called "blead". Some patches may be backported to a maintenance
30454452 226branch. If you think your patch is appropriate for the maintenance
839a0e5a 227branch (see L<perlpolicy/MAINTENANCE BRANCHES>), please explain why
d0bba22e 228when you submit it.
244d9cb7 229
04c692a8 230=head2 Getting your patch accepted
244d9cb7 231
84c2f6fd
DR
232If you are submitting a code patch there are several things that you
233can do to help the Perl 5 Porters accept your patch.
244d9cb7 234
a126fb62
DR
235=head3 Patch style
236
617d9ec4
DB
237Using the GitHub Pull Request workflow, your patch will automatically
238be available in a suitable format. If you wish to submit a patch to
239the p5p list for review, make sure to create it appropriately.
240
a126fb62 241If you used git to check out the Perl source, then using C<git
531e2078 242format-patch> will produce a patch in a style suitable for Perl. The
a126fb62 243C<format-patch> command produces one patch file for each commit you
a44b8c28
S
244made. If you prefer to send a single patch for all commits, you can
245use C<git diff>.
a126fb62 246
9d440a18 247 % git checkout blead
a126fb62
DR
248 % git pull
249 % git diff blead my-branch-name
250
251This produces a patch based on the difference between blead and your
531e2078 252current branch. It's important to make sure that blead is up to date
a126fb62
DR
253before producing the diff, that's why we call C<git pull> first.
254
531e2078 255We strongly recommend that you use git if possible. It will make your
a126fb62
DR
256life easier, and ours as well.
257
258However, if you're not using git, you can still produce a suitable
531e2078
FC
259patch. You'll need a pristine copy of the Perl source to diff against.
260The porters prefer unified diffs. Using GNU C<diff>, you can produce a
a126fb62
DR
261diff like this:
262
263 % diff -Npurd perl.pristine perl.mine
264
265Make sure that you C<make realclean> in your copy of Perl to remove any
266build artifacts, or you may get a confusing result.
267
04c692a8 268=head3 Commit message
244d9cb7 269
04c692a8 270As you craft each patch you intend to submit to the Perl core, it's
531e2078 271important to write a good commit message. This is especially important
04c692a8 272if your submission will consist of a series of commits.
244d9cb7 273
04c692a8 274The first line of the commit message should be a short description
531e2078 275without a period. It should be no longer than the subject line of an
a8d15a22 276email, 50 characters being a good rule of thumb.
f7e1e956 277
a8d15a22 278A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will
04c692a8
DR
279only display the first line (cut off at 50 characters) when presenting
280commit summaries.
7cd58830 281
04c692a8
DR
282The commit message should include a description of the problem that the
283patch corrects or new functionality that the patch adds.
7cd58830 284
04c692a8
DR
285As a general rule of thumb, your commit message should help a
286programmer who knows the Perl core quickly understand what you were
287trying to do, how you were trying to do it, and why the change matters
288to Perl.
7cd58830 289
04c692a8 290=over 4
7cd58830 291
04c692a8 292=item * Why
7cd58830 293
04c692a8 294Your commit message should describe why the change you are making is
531e2078 295important. When someone looks at your change in six months or six
04c692a8 296years, your intent should be clear.
7cd58830 297
04c692a8 298If you're deprecating a feature with the intent of later simplifying
531e2078 299another bit of code, say so. If you're fixing a performance problem or
04c692a8
DR
300adding a new feature to support some other bit of the core, mention
301that.
7cd58830 302
04c692a8 303=item * What
7cd58830 304
04c692a8
DR
305Your commit message should describe what part of the Perl core you're
306changing and what you expect your patch to do.
7cd58830 307
04c692a8 308=item * How
7cd58830 309
04c692a8
DR
310While it's not necessary for documentation changes, new tests or
311trivial patches, it's often worth explaining how your change works.
312Even if it's clear to you today, it may not be clear to a porter next
313month or next year.
d7889f52 314
04c692a8 315=back
d7889f52 316
04c692a8 317A commit message isn't intended to take the place of comments in your
531e2078 318code. Commit messages should describe the change you made, while code
04c692a8 319comments should describe the current state of the code.
d7889f52 320
04c692a8 321If you've just implemented a new feature, complete with doc, tests and
531e2078 322well-commented code, a brief commit message will often suffice. If,
04c692a8
DR
323however, you've just changed a single character deep in the parser or
324lexer, you might need to write a small novel to ensure that future
325readers understand what you did and why you did it.
d7889f52 326
04c692a8 327=head3 Comments, Comments, Comments
d7889f52 328
a44b8c28
S
329Be sure to adequately comment your code. While commenting every line
330is unnecessary, anything that takes advantage of side effects of
04c692a8
DR
331operators, that creates changes that will be felt outside of the
332function being patched, or that others may find confusing should be
a44b8c28
S
333documented. If you are going to err, it is better to err on the side
334of adding too many comments than too few.
d7889f52 335
04c692a8
DR
336The best comments explain I<why> the code does what it does, not I<what
337it does>.
d7889f52 338
04c692a8 339=head3 Style
d7889f52 340
04c692a8
DR
341In general, please follow the particular style of the code you are
342patching.
d7889f52 343
04c692a8
DR
344In particular, follow these general guidelines for patching Perl
345sources:
cce04beb 346
04c692a8 347=over 4
d7889f52
JH
348
349=item *
350
0529658c
AL
3514-wide indents for code, 2-wide indents for nested CPP C<#define>s,
352with 8-wide tabstops.
d7889f52
JH
353
354=item *
355
0529658c
AL
356Use spaces for indentation, not tab characters.
357
358The codebase is a mixture of tabs and spaces for indentation, and we
359are moving to spaces only. Converting lines you're patching from 8-wide
360tabs to spaces will help this migration.
ee9468a2 361
cce04beb 362=item *
ee9468a2 363
04c692a8 364Try hard not to exceed 79-columns
bc028b6b 365
ee9468a2
RGS
366=item *
367
04c692a8 368ANSI C prototypes
d7889f52
JH
369
370=item *
371
04c692a8 372Uncuddled elses and "K&R" style for indenting control constructs
0bec6c03 373
04c692a8 374=item *
d7889f52 375
04c692a8 376No C++ style (//) comments
d7889f52
JH
377
378=item *
379
04c692a8 380Mark places that need to be revisited with XXX (and revisit often!)
27565cb6
JH
381
382=item *
383
04c692a8
DR
384Opening brace lines up with "if" when conditional spans multiple lines;
385should be at end-of-line otherwise
27565cb6 386
04c692a8 387=item *
27565cb6 388
15c526cb 389In function definitions, name starts in column 0 (return value-type is on
04c692a8 390previous line)
27565cb6 391
04c692a8 392=item *
27565cb6 393
04c692a8
DR
394Single space after keywords that are followed by parens, no space
395between function name and following paren
606fd33d 396
27565cb6
JH
397=item *
398
04c692a8
DR
399Avoid assignments in conditionals, but if they're unavoidable, use
400extra paren, e.g. "if (a && (b = c)) ..."
27565cb6
JH
401
402=item *
403
04c692a8 404"return foo;" rather than "return(foo);"
27565cb6
JH
405
406=item *
407
04c692a8 408"if (!foo) ..." rather than "if (foo == FALSE) ..." etc.
606fd33d 409
a8bd0d47
KW
410=item *
411
412Do not declare variables using "register". It may be counterproductive
413with modern compilers, and is deprecated in C++, under which the Perl
414source is regularly compiled.
415
5b48d9bb
KW
416=item *
417
418In-line functions that are in headers that are accessible to XS code
419need to be able to compile without warnings with commonly used extra
420compilation flags, such as gcc's C<-Wswitch-default> which warns
421whenever a switch statement does not have a "default" case. The use of
a44b8c28
S
422these extra flags is to catch potential problems in legal C code, and
423is often used by Perl aggregators, such as Linux distributors.
5b48d9bb 424
606fd33d 425=back
27565cb6 426
04c692a8 427=head3 Test suite
d7889f52 428
a8d15a22 429If your patch changes code (rather than just changing documentation),
04c692a8 430you should also include one or more test cases which illustrate the bug
531e2078 431you're fixing or validate the new functionality you're adding. In
04c692a8
DR
432general, you should update an existing test file rather than create a
433new one.
2bbc8d55 434
04c692a8
DR
435Your test suite additions should generally follow these guidelines
436(courtesy of Gurusamy Sarathy <gsar@activestate.com>):
2bbc8d55 437
04c692a8 438=over 4
0bec6c03 439
04c692a8 440=item *
0bec6c03 441
531e2078 442Know what you're testing. Read the docs, and the source.
ee9468a2
RGS
443
444=item *
445
04c692a8 446Tend to fail, not succeed.
0bec6c03 447
04c692a8 448=item *
0bec6c03 449
04c692a8 450Interpret results strictly.
27565cb6 451
04c692a8 452=item *
27565cb6 453
04c692a8 454Use unrelated features (this will flush out bizarre interactions).
27565cb6 455
04c692a8 456=item *
27565cb6 457
04c692a8 458Use non-standard idioms (otherwise you are not testing TIMTOWTDI).
27565cb6 459
04c692a8 460=item *
d7889f52 461
04c692a8
DR
462Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT
463found in t/op/tie.t is much more maintainable, and gives better failure
464reports).
d7889f52 465
04c692a8 466=item *
d7889f52 467
04c692a8 468Give meaningful error messages when a test fails.
d7889f52 469
04c692a8 470=item *
d7889f52 471
531e2078 472Avoid using qx// and system() unless you are testing for them. If you
04c692a8 473do use them, make sure that you cover _all_ perl platforms.
d7889f52 474
04c692a8 475=item *
0bec6c03 476
04c692a8 477Unlink any temporary files you create.
63796a85 478
04c692a8 479=item *
0bec6c03 480
04c692a8 481Promote unforeseen warnings to errors with $SIG{__WARN__}.
0bec6c03 482
04c692a8 483=item *
0bec6c03 484
04c692a8
DR
485Be sure to use the libraries and modules shipped with the version being
486tested, not those that were already installed.
d7889f52 487
04c692a8 488=item *
d7889f52 489
04c692a8 490Add comments to the code explaining what you are testing for.
d7889f52 491
04c692a8 492=item *
d7889f52 493
531e2078 494Make updating the '1..42' string unnecessary. Or make sure that you
04c692a8 495update it.
d7889f52 496
04c692a8 497=item *
d7889f52 498
04c692a8 499Test _all_ behaviors of a given operator, library, or function.
d7889f52 500
04c692a8 501Test all optional arguments.
d7889f52 502
04c692a8 503Test return values in various contexts (boolean, scalar, list, lvalue).
d7889f52 504
04c692a8 505Use both global and lexical variables.
d7889f52 506
04c692a8 507Don't forget the exceptional, pathological cases.
0bec6c03 508
cce04beb 509=back
0bec6c03 510
04c692a8 511=head2 Patching a core module
ee9468a2 512
04c692a8
DR
513This works just like patching anything else, with one extra
514consideration.
63796a85 515
a8d15a22 516Modules in the F<cpan/> directory of the source tree are maintained
531e2078 517outside of the Perl core. When the author updates the module, the
24b68a05 518updates are simply copied into the core. See that module's
5e17962d 519documentation or its listing on L<https://metacpan.org/> for more
24b68a05
DG
520information on reporting bugs and submitting patches.
521
522In most cases, patches to modules in F<cpan/> should be sent upstream
9e6670f3
DR
523and should not be applied to the Perl core individually. If a patch to
524a file in F<cpan/> absolutely cannot wait for the fix to be made
7e5887a1
DG
525upstream, released to CPAN and copied to blead, you must add (or
526update) a C<CUSTOMIZED> entry in the F<"Porting/Maintainers.pl"> file
527to flag that a local modification has been made. See
528F<"Porting/Maintainers.pl"> for more details.
63796a85 529
04c692a8
DR
530In contrast, modules in the F<dist/> directory are maintained in the
531core.
63796a85 532
04c692a8 533=head2 Updating perldelta
63796a85 534
04c692a8
DR
535For changes significant enough to warrant a F<pod/perldelta.pod> entry,
536the porters will greatly appreciate it if you submit a delta entry
a44b8c28
S
537along with your actual change. Significant changes include, but are
538not limited to:
63796a85 539
04c692a8 540=over 4
63796a85 541
04c692a8 542=item *
63796a85 543
04c692a8 544Adding, deprecating, or removing core features
ee9468a2 545
04c692a8 546=item *
ee9468a2 547
04c692a8 548Adding, deprecating, removing, or upgrading core or dual-life modules
ee9468a2 549
04c692a8 550=item *
ee9468a2 551
04c692a8 552Adding new core tests
ee9468a2 553
04c692a8 554=item *
ee9468a2 555
04c692a8 556Fixing security issues and user-visible bugs in the core
cce04beb 557
04c692a8 558=item *
ad7244db 559
04c692a8 560Changes that might break existing code, either on the perl or C level
ad7244db
JH
561
562=item *
563
04c692a8 564Significant performance improvements
ad7244db
JH
565
566=item *
567
04c692a8
DR
568Adding, removing, or significantly changing documentation in the
569F<pod/> directory
ad7244db 570
cce04beb 571=item *
ad7244db 572
04c692a8 573Important platform-specific changes
d7889f52 574
cce04beb
DG
575=back
576
04c692a8 577Please make sure you add the perldelta entry to the right section
531e2078 578within F<pod/perldelta.pod>. More information on how to write good
04c692a8
DR
579perldelta entries is available in the C<Style> section of
580F<Porting/how_to_write_a_perldelta.pod>.
d7889f52 581
04c692a8 582=head2 What makes for a good patch?
d7889f52 583
531e2078 584New features and extensions to the language can be contentious. There
04c692a8
DR
585is no specific set of criteria which determine what features get added,
586but here are some questions to consider when developing a patch:
d7889f52 587
04c692a8 588=head3 Does the concept match the general goals of Perl?
d7889f52 589
04c692a8 590Our goals include, but are not limited to:
d7889f52 591
04c692a8 592=over 4
d7889f52 593
04c692a8 594=item 1.
d7889f52 595
04c692a8 596Keep it fast, simple, and useful.
cce04beb 597
04c692a8 598=item 2.
cce04beb 599
04c692a8 600Keep features/concepts as orthogonal as possible.
902b9dbf 601
04c692a8 602=item 3.
902b9dbf 603
04c692a8 604No arbitrary limits (platforms, data sizes, cultures).
a958818a 605
04c692a8 606=item 4.
ac036724 607
04c692a8 608Keep it open and exciting to use/patch/advocate Perl everywhere.
a958818a 609
04c692a8 610=item 5.
a958818a 611
04c692a8 612Either assimilate new technologies, or build bridges to them.
a958818a 613
04c692a8 614=back
a958818a 615
04c692a8 616=head3 Where is the implementation?
a958818a 617
531e2078 618All the talk in the world is useless without an implementation. In
04c692a8 619almost every case, the person or people who argue for a new feature
531e2078 620will be expected to be the ones who implement it. Porters capable of
04c692a8
DR
621coding new features have their own agendas, and are not available to
622implement your (possibly good) idea.
a1b65709 623
04c692a8 624=head3 Backwards compatibility
37c0adeb 625
531e2078 626It's a cardinal sin to break existing Perl programs. New warnings can
04c692a8 627be contentious--some say that a program that emits warnings is not
531e2078 628broken, while others say it is. Adding keywords has the potential to
04c692a8
DR
629break programs, changing the meaning of existing token sequences or
630functions might break programs.
f50e5b73 631
04c692a8
DR
632The Perl 5 core includes mechanisms to help porters make backwards
633incompatible changes more compatible such as the L<feature> and
531e2078 634L<deprecate> modules. Please use them when appropriate.
902b9dbf 635
04c692a8 636=head3 Could it be a module instead?
902b9dbf 637
04c692a8 638Perl 5 has extension mechanisms, modules and XS, specifically to avoid
531e2078 639the need to keep changing the Perl interpreter. You can write modules
04c692a8
DR
640that export functions, you can give those functions prototypes so they
641can be called like built-in functions, you can even write XS code to
642mess with the runtime data structures of the Perl interpreter if you
643want to implement really complicated things.
902b9dbf 644
04c692a8
DR
645Whenever possible, new features should be prototyped in a CPAN module
646before they will be considered for the core.
902b9dbf 647
04c692a8 648=head3 Is the feature generic enough?
902b9dbf 649
04c692a8
DR
650Is this something that only the submitter wants added to the language,
651or is it broadly useful? Sometimes, instead of adding a feature with a
652tight focus, the porters might decide to wait until someone implements
653the more generalized feature.
902b9dbf 654
04c692a8 655=head3 Does it potentially introduce new bugs?
902b9dbf 656
04c692a8
DR
657Radical rewrites of large chunks of the Perl interpreter have the
658potential to introduce new bugs.
902b9dbf 659
04c692a8 660=head3 How big is it?
902b9dbf 661
531e2078 662The smaller and more localized the change, the better. Similarly, a
04c692a8 663series of small patches is greatly preferred over a single large patch.
902b9dbf 664
04c692a8 665=head3 Does it preclude other desirable features?
902b9dbf 666
04c692a8 667A patch is likely to be rejected if it closes off future avenues of
531e2078 668development. For instance, a patch that placed a true and final
04c692a8
DR
669interpretation on prototypes is likely to be rejected because there are
670still options for the future of prototypes that haven't been addressed.
902b9dbf 671
04c692a8 672=head3 Is the implementation robust?
902b9dbf 673
04c692a8 674Good patches (tight code, complete, correct) stand more chance of going
531e2078 675in. Sloppy or incorrect patches might be placed on the back burner
66c65f79 676until fixes can be made, or they might be discarded altogether
04c692a8 677without further notice.
902b9dbf 678
04c692a8 679=head3 Is the implementation generic enough to be portable?
902b9dbf 680
531e2078 681The worst patches make use of system-specific features. It's highly
04c692a8
DR
682unlikely that non-portable additions to the Perl language will be
683accepted.
902b9dbf 684
04c692a8 685=head3 Is the implementation tested?
902b9dbf 686
04c692a8
DR
687Patches which change behaviour (fixing bugs or introducing new
688features) must include regression tests to verify that everything works
689as expected.
902b9dbf 690
04c692a8
DR
691Without tests provided by the original author, how can anyone else
692changing perl in the future be sure that they haven't unwittingly
693broken the behaviour the patch implements? And without tests, how can
694the patch's author be confident that his/her hard work put into the
695patch won't be accidentally thrown away by someone in the future?
902b9dbf 696
04c692a8 697=head3 Is there enough documentation?
902b9dbf 698
04c692a8 699Patches without documentation are probably ill-thought out or
531e2078 700incomplete. No features can be added or changed without documentation,
04c692a8
DR
701so submitting a patch for the appropriate pod docs as well as the
702source code is important.
902b9dbf 703
04c692a8 704=head3 Is there another way to do it?
902b9dbf 705
04c692a8 706Larry said "Although the Perl Slogan is I<There's More Than One Way to
531e2078 707Do It>, I hesitate to make 10 ways to do something". This is a tricky
04c692a8
DR
708heuristic to navigate, though--one man's essential addition is another
709man's pointless cruft.
902b9dbf 710
04c692a8 711=head3 Does it create too much work?
902b9dbf 712
66c65f79 713Work for the committers, work for Perl programmers, work for module
04c692a8 714authors, ... Perl is supposed to be easy.
902b9dbf 715
04c692a8 716=head3 Patches speak louder than words
902b9dbf 717
531e2078 718Working code is always preferred to pie-in-the-sky ideas. A patch to
04c692a8
DR
719add a feature stands a much higher chance of making it to the language
720than does a random feature request, no matter how fervently argued the
a44b8c28
S
721request might be. This ties into "Will it be useful?", as the fact
722that someone took the time to make the patch demonstrates a strong
723desire for the feature.
c406981e 724
04c692a8 725=head1 TESTING
c406981e 726
04c692a8
DR
727The core uses the same testing style as the rest of Perl, a simple
728"ok/not ok" run through Test::Harness, but there are a few special
729considerations.
c406981e 730
531e2078 731There are three ways to write a test in the core: L<Test::More>,
a44b8c28
S
732F<t/test.pl> and ad hoc C<print $test ? "ok 42\n" : "not ok 42\n">.
733The decision of which to use depends on what part of the test suite
734you're working on. This is a measure to prevent a high-level failure
735(such as Config.pm breaking) from causing basic functionality tests to
736fail.
c406981e 737
04c692a8
DR
738The F<t/test.pl> library provides some of the features of
739L<Test::More>, but avoids loading most modules and uses as few core
740features as possible.
902b9dbf 741
9e6670f3 742If you write your own test, use the L<Test Anything
71c89d21 743Protocol|https://testanything.org>.
902b9dbf
MLF
744
745=over 4
746
bb52f720 747=item * F<t/base>, F<t/comp> and F<t/opbasic>
902b9dbf 748
15c526cb 749Since we don't know if C<require> works, or even subroutines, use ad hoc
531e2078 750tests for these three. Step carefully to avoid using the feature being
a44b8c28
S
751tested. Tests in F<t/opbasic>, for instance, have been placed there
752rather than in F<t/op> because they test functionality which
753F<t/test.pl> presumes has already been demonstrated to work.
902b9dbf 754
070720ff 755=item * All other subdirectories of F<t/>
902b9dbf 756
04c692a8
DR
757Now that basic require() and subroutines are tested, you can use the
758F<t/test.pl> library.
902b9dbf 759
070720ff 760You can also use certain libraries like L<Config> conditionally, but be
04c692a8 761sure to skip the test gracefully if it's not there.
902b9dbf 762
070720ff 763=item * Test files not found under F<t/>
902b9dbf 764
070720ff
JK
765This category includes F<.t> files underneath directories such as F<dist>,
766F<ext> and F<lib>. Since the core of Perl has now been tested, L<Test::More>
767can and now should be used. You can also use the full suite of core modules
768in the tests. (As noted in L<"Patching a core module"> above, changes to
769F<.t> files found under F<cpan/> should be submitted to the upstream
770maintainers of those modules.)
902b9dbf
MLF
771
772=back
773
a8d15a22 774When you say "make test", Perl uses the F<t/TEST> program to run the
a44b8c28
S
775test suite (except under Win32 where it uses F<t/harness> instead).
776All tests are run from the F<t/> directory, B<not> the directory which
777contains the test. This causes some problems with the tests in
778F<lib/>, so here's some opportunity for some patching.
902b9dbf 779
531e2078 780You must be triply conscious of cross-platform concerns. This usually
eb9df707
KW
781boils down to using L<File::Spec>, avoiding things like C<fork()>
782and C<system()> unless absolutely necessary, and not assuming that a
783given character has a particular ordinal value (code point) or that its
784UTF-8 representation is composed of particular bytes.
785
786There are several functions available to specify characters and code
787points portably in tests. The always-preloaded functions
788C<utf8::unicode_to_native()> and its inverse
789C<utf8::native_to_unicode()> take code points and translate
790appropriately. The file F<t/charset_tools.pl> has several functions
791that can be useful. It has versions of the previous two functions
792that take strings as inputs -- not single numeric code points:
793C<uni_to_native()> and C<native_to_uni()>. If you must look at the
794individual bytes comprising a UTF-8 encoded string,
795C<byte_utf8a_to_utf8n()> takes as input a string of those bytes encoded
796for an ASCII platform, and returns the equivalent string in the native
797platform. For example, C<byte_utf8a_to_utf8n("\xC2\xA0")> returns the
798byte sequence on the current platform that form the UTF-8 for C<U+00A0>,
799since C<"\xC2\xA0"> are the UTF-8 bytes on an ASCII platform for that
800code point. This function returns C<"\xC2\xA0"> on an ASCII platform, and
801C<"\x80\x41"> on an EBCDIC 1047 one.
802
15c526cb 803But easiest is, if the character is specifiable as a literal, like
a3815e44 804C<"A"> or C<"%">, to use that; if not so specificable, you can use
15c526cb
KW
805C<\N{}> , if the side effects aren't troublesome. Simply specify all
806your characters in hex, using C<\N{U+ZZ}> instead of C<\xZZ>. C<\N{}>
807is the Unicode name, and so it
eb9df707
KW
808always gives you the Unicode character. C<\N{U+41}> is the character
809whose Unicode code point is C<0x41>, hence is C<'A'> on all platforms.
810The side effects are:
811
812=over 4
813
3f9568ff 814=item *
eb9df707
KW
815
816These select Unicode rules. That means that in double-quotish strings,
817the string is always converted to UTF-8 to force a Unicode
818interpretation (you can C<utf8::downgrade()> afterwards to convert back
819to non-UTF8, if possible). In regular expression patterns, the
820conversion isn't done, but if the character set modifier would
821otherwise be C</d>, it is changed to C</u>.
822
3f9568ff 823=item *
eb9df707
KW
824
825If you use the form C<\N{I<character name>}>, the L<charnames> module
826gets automatically loaded. This may not be suitable for the test level
827you are doing.
828
829=back
7a834142 830
15c526cb
KW
831If you are testing locales (see L<perllocale>), there are helper
832functions in F<t/loc_tools.pl> to enable you to see what locales there
833are on the current platform.
834
04c692a8 835=head2 Special C<make test> targets
07aa3531 836
04c692a8 837There are various special make targets that can be used to test Perl
531e2078
FC
838slightly differently than the standard "test" target. Not all them are
839expected to give a 100% success rate. Many of them have several
04c692a8
DR
840aliases, and many of them are not available on certain operating
841systems.
07aa3531 842
04c692a8 843=over 4
d44161bf 844
04c692a8 845=item * test_porting
7a834142 846
04c692a8
DR
847This runs some basic sanity tests on the source tree and helps catch
848basic errors before you submit a patch.
7a834142 849
04c692a8 850=item * minitest
51a35ef1 851
04c692a8
DR
852Run F<miniperl> on F<t/base>, F<t/comp>, F<t/cmd>, F<t/run>, F<t/io>,
853F<t/op>, F<t/uni> and F<t/mro> tests.
51a35ef1 854
f9d2c26d
TC
855F<miniperl> is a minimalistic perl built to bootstrap building
856extensions, utilties, documentation etc. It doesn't support dynamic
857loading and depending on the point in the build process will only have
858access to a limited set of core modules. F<miniperl> is not intended
859for day to day use.
860
499cea6b 861=item * test.valgrind check.valgrind
51a35ef1 862
04c692a8 863(Only in Linux) Run all the tests using the memory leak + naughty
531e2078 864memory access tool "valgrind". The log files will be named
04c692a8 865F<testname.valgrind>.
83f0ef60 866
04c692a8 867=item * test_harness
83f0ef60 868
04c692a8 869Run the test suite with the F<t/harness> controlling program, instead
531e2078 870of F<t/TEST>. F<t/harness> is more sophisticated, and uses the
04c692a8 871L<Test::Harness> module, thus using this test target supposes that perl
531e2078 872mostly works. The main advantage for our purposes is that it prints a
a44b8c28
S
873detailed summary of failed tests at the end. Also, unlike F<t/TEST>,
874it doesn't redirect stderr to stdout.
83f0ef60 875
04c692a8
DR
876Note that under Win32 F<t/harness> is always used instead of F<t/TEST>,
877so there is no special "test_harness" target.
83f0ef60 878
04c692a8
DR
879Under Win32's "test" target you may use the TEST_SWITCHES and
880TEST_FILES environment variables to control the behaviour of
531e2078 881F<t/harness>. This means you can say
83f0ef60 882
04c692a8
DR
883 nmake test TEST_FILES="op/*.t"
884 nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t"
83f0ef60 885
78087e0a
R
886=item * test-notty test_notty
887
888Sets PERL_SKIP_TTY_TEST to true before running normal test.
889
83f0ef60
JH
890=back
891
04c692a8 892=head2 Parallel tests
83f0ef60 893
04c692a8 894The core distribution can now run its regression tests in parallel on
730797bb
KW
895Unix-like and Windows platforms. On Unix, instead of running C<make
896test>, set C<TEST_JOBS> in your environment to the number of tests to
897run in parallel, and run C<make test_harness>. On a Bourne-like shell,
898this can be done as
07aa3531 899
04c692a8 900 TEST_JOBS=3 make test_harness # Run 3 tests in parallel
07aa3531 901
04c692a8
DR
902An environment variable is used, rather than parallel make itself,
903because L<TAP::Harness> needs to be able to schedule individual
904non-conflicting test scripts itself, and there is no standard interface
905to C<make> utilities to interact with their job schedulers.
51a35ef1 906
730797bb
KW
907Tests are normally run in a logical order, with the sanity tests first,
908then the main tests of the Perl core functionality, then the tests for
909the non-core modules. On many-core systems, this may not use the
910hardware as effectively as possible. By also specifying
911
912 TEST_JOBS=19 PERL_TEST_HARNESS_ASAP=1 make -j19 test_harness
913
914you signal that you want the tests to finish in wall-clock time as short
915as possible. After the sanity tests are completed, this causes the
916remaining ones to be packed into the available cores as tightly as
917we know how. This has its greatest effect on slower, many-core systems.
918Throughput was sped up by 20% on an outmoded 24-core system; less on
919more recent faster ones with fewer cores.
920
921Note that the command line above added a C<-j> parameter to make, so as
922to cause parallel compilation. This may or may not work on your
923platform.
51a35ef1 924
04c692a8 925=head2 Running tests by hand
51a35ef1 926
9e6670f3
DR
927You can run part of the test suite by hand by using one of the
928following commands from the F<t/> directory:
51a35ef1 929
04c692a8 930 ./perl -I../lib TEST list-of-.t-files
51a35ef1 931
04c692a8 932or
51a35ef1 933
04c692a8 934 ./perl -I../lib harness list-of-.t-files
51a35ef1 935
a8d15a22 936(If you don't specify test scripts, the whole test suite will be run.)
51a35ef1 937
04c692a8 938=head2 Using F<t/harness> for testing
51a35ef1 939
9e6670f3 940If you use C<harness> for testing, you have several command line
531e2078 941options available to you. The arguments are as follows, and are in the
9e6670f3 942order that they must appear if used together.
51a35ef1 943
04c692a8
DR
944 harness -v -torture -re=pattern LIST OF FILES TO TEST
945 harness -v -torture -re LIST OF PATTERNS TO MATCH
07aa3531 946
a8d15a22 947If C<LIST OF FILES TO TEST> is omitted, the file list is obtained from
531e2078 948the manifest. The file list may include shell wildcards which will be
04c692a8 949expanded out.
07aa3531 950
04c692a8 951=over 4
4ae3d70a 952
04c692a8 953=item * -v
4ae3d70a 954
04c692a8
DR
955Run the tests under verbose mode so you can see what tests were run,
956and debug output.
51a35ef1 957
04c692a8 958=item * -torture
4ae3d70a 959
04c692a8 960Run the torture tests as well as the normal set.
4ae3d70a 961
04c692a8 962=item * -re=PATTERN
6c41479b 963
a44b8c28
S
964Filter the file list so that all the test files run match PATTERN.
965Note that this form is distinct from the B<-re LIST OF PATTERNS> form
966below in that it allows the file list to be provided as well.
6c41479b 967
04c692a8 968=item * -re LIST OF PATTERNS
6c41479b 969
04c692a8 970Filter the file list so that all the test files run match
531e2078 971/(LIST|OF|PATTERNS)/. Note that with this form the patterns are joined
04c692a8
DR
972by '|' and you cannot supply a list of files, instead the test files
973are obtained from the MANIFEST.
6c41479b 974
04c692a8 975=back
6c41479b 976
04c692a8 977You can run an individual test by a command similar to
6c41479b 978
a8d15a22 979 ./perl -I../lib path/to/foo.t
6c41479b 980
04c692a8
DR
981except that the harnesses set up some environment variables that may
982affect the execution of the test:
6c41479b
JH
983
984=over 4
985
04c692a8 986=item * PERL_CORE=1
6c41479b 987
a8d15a22 988indicates that we're running this test as part of the perl core test
531e2078 989suite. This is useful for modules that have a dual life on CPAN.
6c41479b 990
04c692a8 991=item * PERL_DESTRUCT_LEVEL=2
6c41479b 992
04c692a8 993is set to 2 if it isn't set already (see
a8d15a22 994L<perlhacktips/PERL_DESTRUCT_LEVEL>).
6c41479b 995
04c692a8 996=item * PERL
6c41479b 997
04c692a8
DR
998(used only by F<t/TEST>) if set, overrides the path to the perl
999executable that should be used to run the tests (the default being
1000F<./perl>).
6c41479b 1001
04c692a8 1002=item * PERL_SKIP_TTY_TEST
6c41479b 1003
a44b8c28
S
1004if set, tells to skip the tests that need a terminal. It's actually
1005set automatically by the Makefile, but can also be forced artificially
1006by running 'make test_notty'.
6c41479b 1007
04c692a8 1008=back
6c41479b 1009
04c692a8 1010=head3 Other environment variables that may influence tests
6c41479b 1011
04c692a8 1012=over 4
6c41479b 1013
04c692a8 1014=item * PERL_TEST_Net_Ping
6c41479b 1015
04c692a8 1016Setting this variable runs all the Net::Ping modules tests, otherwise
531e2078 1017some tests that interact with the outside world are skipped. See
04c692a8 1018L<perl58delta>.
6c41479b 1019
04c692a8 1020=item * PERL_TEST_NOVREXX
cce04beb 1021
04c692a8 1022Setting this variable skips the vrexx.t tests for OS2::REXX.
cce04beb 1023
04c692a8 1024=item * PERL_TEST_NUMCONVERTS
cce04beb 1025
04c692a8 1026This sets a variable in op/numconvert.t.
cce04beb 1027
ff5db609
TC
1028=item * PERL_TEST_MEMORY
1029
1030Setting this variable includes the tests in F<t/bigmem/>. This should
a44b8c28
S
1031be set to the number of gigabytes of memory available for testing, eg.
1032C<PERL_TEST_MEMORY=4> indicates that tests that require 4GiB of
ff5db609
TC
1033available memory can be run safely.
1034
04c692a8 1035=back
cce04beb 1036
04c692a8
DR
1037See also the documentation for the Test and Test::Harness modules, for
1038more environment variables that affect testing.
cce04beb 1039
9e7973fa
DM
1040=head2 Performance testing
1041
1042The file F<t/perf/benchmarks> contains snippets of perl code which are
1043intended to be benchmarked across a range of perls by the
1044F<Porting/bench.pl> tool. If you fix or enhance a performance issue, you
1045may want to add a representative code sample to the file, then run
1046F<bench.pl> against the previous and current perls to see what difference
1047it has made, and whether anything else has slowed down as a consequence.
1048
1049The file F<t/perf/opcount.t> is designed to test whether a particular
1050code snippet has been compiled into an optree containing specified
1051numbers of particular op types. This is good for testing whether
1052optimisations which alter ops, such as converting an C<aelem> op into an
1053C<aelemfast> op, are really doing that.
1054
1055The files F<t/perf/speed.t> and F<t/re/speed.t> are designed to test
1056things that run thousands of times slower if a particular optimisation
1057is broken (for example, the utf8 length cache on long utf8 strings).
1058Add a test that will take a fraction of a second normally, and minutes
1059otherwise, causing the test file to time out on failure.
1060
ca31f56c
JK
1061=head2 Building perl at older commits
1062
1063In the course of hacking on the Perl core distribution, you may have occasion
1064to configure, build and test perl at an old commit. Sometimes C<make> will
1065fail during this process. If that happens, you may be able to salvage the
1066situation by using the Devel::PatchPerl library from CPAN (not included in the
1067core) to bring the source code at that commit to a buildable state.
1068
1069Here's a real world example, taken from work done to resolve
8034715d 1070L<perl #10118|https://github.com/Perl/perl5/issues/10118>.
ca31f56c
JK
1071Use of F<Porting/bisect.pl> had identified commit
1072C<ba77e4cc9d1ceebf472c9c5c18b2377ee47062e6> as the commit in which a bug was
1073corrected. To confirm, a P5P developer wanted to configure and build perl at
1074commit C<ba77e4c^> (presumably "bad") and then at C<ba77e4c> (presumably
1075"good"). Normal configuration and build was attempted:
1076
1077 $ sh ./Configure -des -Dusedevel
1078 $ make test_prep
1079
1080C<make>, however, failed with output (excerpted) like this:
1081
1082 cc -fstack-protector -L/usr/local/lib -o miniperl \
1083 gv.o toke.o perly.o pad.o regcomp.o dump.o util.o \
1084 mg.o reentr.o mro.o hv.o av.o run.o pp_hot.o sv.o \
1085 pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o \
1086 utf8.o taint.o deb.o universal.o globals.o perlio.o \
8c3a0f6c 1087 numeric.o mathoms.o locale.o pp_pack.o pp_sort.o \
ca31f56c
JK
1088 miniperlmain.o opmini.o perlmini.o
1089 pp.o: In function `Perl_pp_pow':
1090 pp.c:(.text+0x2db9): undefined reference to `pow'
1091 ...
1092 collect2: error: ld returned 1 exit status
1093 makefile:348: recipe for target 'miniperl' failed
1094 make: *** [miniperl] Error 1
1095
1096Another P5P contributor recommended installation and use of Devel::PatchPerl
1097for this situation, first to determine the version of perl at the commit in
1098question, then to patch the source code at that point to facilitate a build.
1099
1100 $ perl -MDevel::PatchPerl -e \
1101 'print Devel::PatchPerl->determine_version("/path/to/sourcecode"), "\n";'
1102 5.11.1
1103 $ perl -MDevel::PatchPerl -e \
1104 'Devel::PatchPerl->patch_source("5.11.1", "/path/to/sourcecode");'
1105
1106Once the source was patched, C<./Configure> and C<make test_prep> were called
1107and completed successfully, enabling confirmation of the findings in RT
1108#72414.
1109
04c692a8 1110=head1 MORE READING FOR GUTS HACKERS
cce04beb 1111
04c692a8 1112To hack on the Perl guts, you'll need to read the following things:
cce04beb 1113
04c692a8 1114=over 4
cce04beb 1115
04c692a8 1116=item * L<perlsource>
b8ddf6b3 1117
531e2078 1118An overview of the Perl source tree. This will help you find the files
04c692a8 1119you're looking for.
b8ddf6b3 1120
04c692a8 1121=item * L<perlinterp>
b8ddf6b3 1122
04c692a8
DR
1123An overview of the Perl interpreter source code and some details on how
1124Perl does what it does.
b8ddf6b3 1125
04c692a8 1126=item * L<perlhacktut>
b8ddf6b3 1127
04c692a8 1128This document walks through the creation of a small patch to Perl's C
531e2078 1129code. If you're just getting started with Perl core hacking, this will
04c692a8 1130help you understand how it works.
b8ddf6b3 1131
04c692a8 1132=item * L<perlhacktips>
b8ddf6b3 1133
531e2078 1134More details on hacking the Perl core. This document focuses on lower
04c692a8
DR
1135level details such as how to write tests, compilation issues,
1136portability, debugging, etc.
b8ddf6b3 1137
04c692a8 1138If you plan on doing serious C hacking, make sure to read this.
b8ddf6b3 1139
04c692a8 1140=item * L<perlguts>
b8ddf6b3 1141
04c692a8 1142This is of paramount importance, since it's the documentation of what
531e2078 1143goes where in the Perl source. Read it over a couple of times and it
04c692a8
DR
1144might start to make sense - don't worry if it doesn't yet, because the
1145best way to study it is to read it in conjunction with poking at Perl
1146source, and we'll do that later on.
b8ddf6b3 1147
04c692a8
DR
1148Gisle Aas's "illustrated perlguts", also known as I<illguts>, has very
1149helpful pictures:
9965345d 1150
082a0fe7 1151L<https://metacpan.org/release/RURBAN/illguts-0.49>
9965345d 1152
04c692a8 1153=item * L<perlxstut> and L<perlxs>
f1fac472 1154
04c692a8
DR
1155A working knowledge of XSUB programming is incredibly useful for core
1156hacking; XSUBs use techniques drawn from the PP code, the portion of
531e2078 1157the guts that actually executes a Perl program. It's a lot gentler to
04c692a8
DR
1158learn those techniques from simple examples and explanation than from
1159the core itself.
f1fac472 1160
04c692a8 1161=item * L<perlapi>
f1fac472 1162
04c692a8
DR
1163The documentation for the Perl API explains what some of the internal
1164functions do, as well as the many macros used in the source.
f1fac472 1165
04c692a8 1166=item * F<Porting/pumpkin.pod>
f1fac472 1167
04c692a8 1168This is a collection of words of wisdom for a Perl porter; some of it
66c65f79 1169is only useful to the pumpkin holders, but most of it applies to anyone
04c692a8 1170wanting to go about Perl development.
f1fac472 1171
04c692a8 1172=back
f1fac472 1173
04c692a8 1174=head1 CPAN TESTERS AND PERL SMOKERS
f1fac472 1175
71c89d21 1176The CPAN testers ( L<http://cpantesters.org/> ) are a group of volunteers
04c692a8 1177who test CPAN modules on a variety of platforms.
b8ddf6b3 1178
71c89d21
MM
1179Perl Smokers ( L<https://www.nntp.perl.org/group/perl.daily-build/> and
1180L<https://www.nntp.perl.org/group/perl.daily-build.reports/> )
04c692a8
DR
1181automatically test Perl source releases on platforms with various
1182configurations.
f1fac472 1183
531e2078 1184Both efforts welcome volunteers. In order to get involved in smoke
04c692a8 1185testing of the perl itself visit
c23f766f 1186L<https://metacpan.org/release/Test-Smoke>. In order to start smoke
04c692a8 1187testing CPAN modules visit
c23f766f
DB
1188L<https://metacpan.org/release/CPANPLUS-YACSmoke> or
1189L<https://metacpan.org/release/minismokebox> or
1190L<https://metacpan.org/release/CPAN-Reporter>.
f1fac472 1191
04c692a8 1192=head1 WHAT NEXT?
a422fd2d 1193
04c692a8
DR
1194If you've read all the documentation in the document and the ones
1195listed above, you're more than ready to hack on Perl.
a422fd2d 1196
04c692a8 1197Here's some more recommendations
a422fd2d 1198
04c692a8 1199=over 4
a422fd2d
SC
1200
1201=item *
1202
1203Subscribe to perl5-porters, follow the patches and try and understand
1204them; don't be afraid to ask if there's a portion you're not clear on -
1205who knows, you may unearth a bug in the patch...
1206
1207=item *
1208
04c692a8 1209Do read the README associated with your operating system, e.g.
531e2078 1210README.aix on the IBM AIX OS. Don't hesitate to supply patches to that
04c692a8 1211README if you find anything missing or changed over a new OS release.
a1f349fd
MB
1212
1213=item *
1214
a422fd2d 1215Find an area of Perl that seems interesting to you, and see if you can
a44b8c28
S
1216work out how it works. Scan through the source, and step over it in
1217the debugger. Play, poke, investigate, fiddle! You'll probably get to
04c692a8
DR
1218understand not just your chosen area but a much wider range of
1219F<perl>'s activity as well, and probably sooner than you'd think.
a422fd2d
SC
1220
1221=back
1222
04c692a8 1223=head2 "The Road goes ever on and on, down from the door where it began."
a422fd2d 1224
04c692a8 1225If you can do these things, you've started on the long road to Perl
531e2078 1226porting. Thanks for wanting to help make Perl better - and happy
04c692a8 1227hacking!
a422fd2d 1228
4ac71550
TC
1229=head2 Metaphoric Quotations
1230
1231If you recognized the quote about the Road above, you're in luck.
1232
04c692a8 1233Most software projects begin each file with a literal description of
531e2078 1234each file's purpose. Perl instead begins each with a literary allusion
04c692a8 1235to that file's purpose.
4ac71550 1236
04c692a8 1237Like chapters in many books, all top-level Perl source files (along
9e6670f3
DR
1238with a few others here and there) begin with an epigrammatic
1239inscription that alludes, indirectly and metaphorically, to the
1240material you're about to read.
4ac71550 1241
a8d15a22 1242Quotations are taken from writings of J.R.R. Tolkien pertaining to his
531e2078 1243Legendarium, almost always from I<The Lord of the Rings>. Chapters and
4ac71550
TC
1244page numbers are given using the following editions:
1245
1246=over 4
1247
04c692a8 1248=item *
4ac71550 1249
531e2078 1250I<The Hobbit>, by J.R.R. Tolkien. The hardcover, 70th-anniversary
04c692a8
DR
1251edition of 2007 was used, published in the UK by Harper Collins
1252Publishers and in the US by the Houghton Mifflin Company.
4ac71550
TC
1253
1254=item *
1255
531e2078 1256I<The Lord of the Rings>, by J.R.R. Tolkien. The hardcover,
04c692a8
DR
125750th-anniversary edition of 2004 was used, published in the UK by
1258Harper Collins Publishers and in the US by the Houghton Mifflin
1259Company.
4ac71550
TC
1260
1261=item *
1262
04c692a8
DR
1263I<The Lays of Beleriand>, by J.R.R. Tolkien and published posthumously
1264by his son and literary executor, C.J.R. Tolkien, being the 3rd of the
531e2078 126512 volumes in Christopher's mammoth I<History of Middle Earth>. Page
04c692a8
DR
1266numbers derive from the hardcover edition, first published in 1983 by
1267George Allen & Unwin; no page numbers changed for the special 3-volume
1268omnibus edition of 2002 or the various trade-paper editions, all again
1269now by Harper Collins or Houghton Mifflin.
4ac71550
TC
1270
1271=back
1272
04c692a8
DR
1273Other JRRT books fair game for quotes would thus include I<The
1274Adventures of Tom Bombadil>, I<The Silmarillion>, I<Unfinished Tales>,
1275and I<The Tale of the Children of Hurin>, all but the first
531e2078 1276posthumously assembled by CJRT. But I<The Lord of the Rings> itself is
04c692a8
DR
1277perfectly fine and probably best to quote from, provided you can find a
1278suitable quote there.
4ac71550 1279
04c692a8
DR
1280So if you were to supply a new, complete, top-level source file to add
1281to Perl, you should conform to this peculiar practice by yourself
1282selecting an appropriate quotation from Tolkien, retaining the original
1283spelling and punctuation and using the same format the rest of the
531e2078 1284quotes are in. Indirect and oblique is just fine; remember, it's a
04c692a8 1285metaphor, so being meta is, after all, what it's for.
4ac71550 1286
e8cd7eae
GS
1287=head1 AUTHOR
1288
04c692a8
DR
1289This document was originally written by Nathan Torkington, and is
1290maintained by the perl5-porters mailing list.