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