Debian Codegraph @

upstream/fedora-44/man1/perlhack.1

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