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