Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man1 / perlhack.1
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "PERLHACK 1"
132.TH PERLHACK 1 "2002-06-08" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134perlhack \- How to hack at the Perl internals
135.SH "DESCRIPTION"
136.IX Header "DESCRIPTION"
137This document attempts to explain how Perl development takes place,
138and ends with some suggestions for people wanting to become bona fide
139porters.
140.PP
141The perl5\-porters mailing list is where the Perl standard distribution
142is maintained and developed. The list can get anywhere from 10 to 150
143messages a day, depending on the heatedness of the debate. Most days
144there are two or three patches, extensions, features, or bugs being
145discussed at a time.
146.PP
147A searchable archive of the list is at either:
148.PP
149.Vb 1
150\& http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/
151.Ve
152.PP
153or
154.PP
155.Vb 1
156\& http://archive.develooper.com/perl5-porters@perl.org/
157.Ve
158.PP
159List subscribers (the porters themselves) come in several flavours.
160Some are quiet curious lurkers, who rarely pitch in and instead watch
161the ongoing development to ensure they're forewarned of new changes or
162features in Perl. Some are representatives of vendors, who are there
163to make sure that Perl continues to compile and work on their
164platforms. Some patch any reported bug that they know how to fix,
165some are actively patching their pet area (threads, Win32, the regexp
166engine), while others seem to do nothing but complain. In other
167words, it's your usual mix of technical people.
168.PP
169Over this group of porters presides Larry Wall. He has the final word
170in what does and does not change in the Perl language. Various
171releases of Perl are shepherded by a ``pumpking'', a porter
172responsible for gathering patches, deciding on a patch-by-patch
173feature-by-feature basis what will and will not go into the release.
174For instance, Gurusamy Sarathy was the pumpking for the 5.6 release of
175Perl, and Jarkko Hietaniemi is the pumpking for the 5.8 release, and
176Hugo van der Sanden will be the pumpking for the 5.10 release.
177.PP
178In addition, various people are pumpkings for different things. For
179instance, Andy Dougherty and Jarkko Hietaniemi share the \fIConfigure\fR
180pumpkin.
181.PP
182Larry sees Perl development along the lines of the \s-1US\s0 government:
183there's the Legislature (the porters), the Executive branch (the
184pumpkings), and the Supreme Court (Larry). The legislature can
185discuss and submit patches to the executive branch all they like, but
186the executive branch is free to veto them. Rarely, the Supreme Court
187will side with the executive branch over the legislature, or the
188legislature over the executive branch. Mostly, however, the
189legislature and the executive branch are supposed to get along and
190work out their differences without impeachment or court cases.
191.PP
192You might sometimes see reference to Rule 1 and Rule 2. Larry's power
193as Supreme Court is expressed in The Rules:
194.IP "1" 4
195.IX Item "1"
196Larry is always by definition right about how Perl should behave.
197This means he has final veto power on the core functionality.
198.IP "2" 4
199.IX Item "2"
200Larry is allowed to change his mind about any matter at a later date,
201regardless of whether he previously invoked Rule 1.
202.PP
203Got that? Larry is always right, even when he was wrong. It's rare
204to see either Rule exercised, but they are often alluded to.
205.PP
206New features and extensions to the language are contentious, because
207the criteria used by the pumpkings, Larry, and other porters to decide
208which features should be implemented and incorporated are not codified
209in a few small design goals as with some other languages. Instead,
210the heuristics are flexible and often difficult to fathom. Here is
211one person's list, roughly in decreasing order of importance, of
212heuristics that new features have to be weighed against:
213.IP "Does concept match the general goals of Perl?" 4
214.IX Item "Does concept match the general goals of Perl?"
215These haven't been written anywhere in stone, but one approximation
216is:
217.Sp
218.Vb 5
219\& 1. Keep it fast, simple, and useful.
220\& 2. Keep features/concepts as orthogonal as possible.
221\& 3. No arbitrary limits (platforms, data sizes, cultures).
222\& 4. Keep it open and exciting to use/patch/advocate Perl everywhere.
223\& 5. Either assimilate new technologies, or build bridges to them.
224.Ve
225.IP "Where is the implementation?" 4
226.IX Item "Where is the implementation?"
227All the talk in the world is useless without an implementation. In
228almost every case, the person or people who argue for a new feature
229will be expected to be the ones who implement it. Porters capable
230of coding new features have their own agendas, and are not available
231to implement your (possibly good) idea.
232.IP "Backwards compatibility" 4
233.IX Item "Backwards compatibility"
234It's a cardinal sin to break existing Perl programs. New warnings are
235contentious\*(--some say that a program that emits warnings is not
236broken, while others say it is. Adding keywords has the potential to
237break programs, changing the meaning of existing token sequences or
238functions might break programs.
239.IP "Could it be a module instead?" 4
240.IX Item "Could it be a module instead?"
241Perl 5 has extension mechanisms, modules and \s-1XS\s0, specifically to avoid
242the need to keep changing the Perl interpreter. You can write modules
243that export functions, you can give those functions prototypes so they
244can be called like built-in functions, you can even write \s-1XS\s0 code to
245mess with the runtime data structures of the Perl interpreter if you
246want to implement really complicated things. If it can be done in a
247module instead of in the core, it's highly unlikely to be added.
248.IP "Is the feature generic enough?" 4
249.IX Item "Is the feature generic enough?"
250Is this something that only the submitter wants added to the language,
251or would it be broadly useful? Sometimes, instead of adding a feature
252with a tight focus, the porters might decide to wait until someone
253implements the more generalized feature. For instance, instead of
254implementing a ``delayed evaluation'' feature, the porters are waiting
255for a macro system that would permit delayed evaluation and much more.
256.IP "Does it potentially introduce new bugs?" 4
257.IX Item "Does it potentially introduce new bugs?"
258Radical rewrites of large chunks of the Perl interpreter have the
259potential to introduce new bugs. The smaller and more localized the
260change, the better.
261.IP "Does it preclude other desirable features?" 4
262.IX Item "Does it preclude other desirable features?"
263A patch is likely to be rejected if it closes off future avenues of
264development. For instance, a patch that placed a true and final
265interpretation on prototypes is likely to be rejected because there
266are still options for the future of prototypes that haven't been
267addressed.
268.IP "Is the implementation robust?" 4
269.IX Item "Is the implementation robust?"
270Good patches (tight code, complete, correct) stand more chance of
271going in. Sloppy or incorrect patches might be placed on the back
272burner until the pumpking has time to fix, or might be discarded
273altogether without further notice.
274.IP "Is the implementation generic enough to be portable?" 4
275.IX Item "Is the implementation generic enough to be portable?"
276The worst patches make use of a system-specific features. It's highly
277unlikely that nonportable additions to the Perl language will be
278accepted.
279.IP "Is the implementation tested?" 4
280.IX Item "Is the implementation tested?"
281Patches which change behaviour (fixing bugs or introducing new features)
282must include regression tests to verify that everything works as expected.
283Without tests provided by the original author, how can anyone else changing
284perl in the future be sure that they haven't unwittingly broken the behaviour
285the patch implements? And without tests, how can the patch's author be
286confident that his/her hard work put into the patch won't be accidentally
287thrown away by someone in the future?
288.IP "Is there enough documentation?" 4
289.IX Item "Is there enough documentation?"
290Patches without documentation are probably ill-thought out or
291incomplete. Nothing can be added without documentation, so submitting
292a patch for the appropriate manpages as well as the source code is
293always a good idea.
294.IP "Is there another way to do it?" 4
295.IX Item "Is there another way to do it?"
296Larry said ``Although the Perl Slogan is \fIThere's More Than One Way
297to Do It\fR, I hesitate to make 10 ways to do something''. This is a
298tricky heuristic to navigate, though\*(--one man's essential addition is
299another man's pointless cruft.
300.IP "Does it create too much work?" 4
301.IX Item "Does it create too much work?"
302Work for the pumpking, work for Perl programmers, work for module
303authors, ... Perl is supposed to be easy.
304.IP "Patches speak louder than words" 4
305.IX Item "Patches speak louder than words"
306Working code is always preferred to pie-in-the-sky ideas. A patch to
307add a feature stands a much higher chance of making it to the language
308than does a random feature request, no matter how fervently argued the
309request might be. This ties into ``Will it be useful?'', as the fact
310that someone took the time to make the patch demonstrates a strong
311desire for the feature.
312.PP
313If you're on the list, you might hear the word ``core'' bandied
314around. It refers to the standard distribution. ``Hacking on the
315core'' means you're changing the C source code to the Perl
316interpreter. ``A core module'' is one that ships with Perl.
317.Sh "Keeping in sync"
318.IX Subsection "Keeping in sync"
319The source code to the Perl interpreter, in its different versions, is
320kept in a repository managed by a revision control system ( which is
321currently the Perforce program, see http://perforce.com/ ). The
322pumpkings and a few others have access to the repository to check in
323changes. Periodically the pumpking for the development version of Perl
324will release a new version, so the rest of the porters can see what's
325changed. The current state of the main trunk of repository, and patches
326that describe the individual changes that have happened since the last
327public release are available at this location:
328.PP
329.Vb 2
330\& http://public.activestate.com/gsar/APC/
331\& ftp://ftp.linux.activestate.com/pub/staff/gsar/APC/
332.Ve
333.PP
334If you're looking for a particular change, or a change that affected
335a particular set of files, you may find the \fBPerl Repository Browser\fR
336useful:
337.PP
338.Vb 1
339\& http://public.activestate.com/cgi-bin/perlbrowse
340.Ve
341.PP
342You may also want to subscribe to the perl5\-changes mailing list to
343receive a copy of each patch that gets submitted to the maintenance
344and development \*(L"branches\*(R" of the perl repository. See
345http://lists.perl.org/ for subscription information.
346.PP
347If you are a member of the perl5\-porters mailing list, it is a good
348thing to keep in touch with the most recent changes. If not only to
349verify if what you would have posted as a bug report isn't already
350solved in the most recent available perl development branch, also
351known as perl\-current, bleading edge perl, bleedperl or bleadperl.
352.PP
353Needless to say, the source code in perl-current is usually in a perpetual
354state of evolution. You should expect it to be very buggy. Do \fBnot\fR use
355it for any purpose other than testing and development.
356.PP
357Keeping in sync with the most recent branch can be done in several ways,
358but the most convenient and reliable way is using \fBrsync\fR, available at
359ftp://rsync.samba.org/pub/rsync/ . (You can also get the most recent
360branch by \s-1FTP\s0.)
361.PP
362If you choose to keep in sync using rsync, there are two approaches
363to doing so:
364.IP "rsync'ing the source tree" 4
365.IX Item "rsync'ing the source tree"
366Presuming you are in the directory where your perl source resides
367and you have rsync installed and available, you can `upgrade' to
368the bleadperl using:
369.Sp
370.Vb 1
371\& # rsync -avz rsync://ftp.linux.activestate.com/perl-current/ .
372.Ve
373.Sp
374This takes care of updating every single item in the source tree to
375the latest applied patch level, creating files that are new (to your
376distribution) and setting date/time stamps of existing files to
377reflect the bleadperl status.
378.Sp
379Note that this will not delete any files that were in '.' before
380the rsync. Once you are sure that the rsync is running correctly,
381run it with the \-\-delete and the \-\-dry\-run options like this:
382.Sp
383.Vb 1
384\& # rsync -avz --delete --dry-run rsync://ftp.linux.activestate.com/perl-current/ .
385.Ve
386.Sp
387This will \fIsimulate\fR an rsync run that also deletes files not
388present in the bleadperl master copy. Observe the results from
389this run closely. If you are sure that the actual run would delete
390no files precious to you, you could remove the '\-\-dry\-run' option.
391.Sp
392You can than check what patch was the latest that was applied by
393looking in the file \fB.patch\fR, which will show the number of the
394latest patch.
395.Sp
396If you have more than one machine to keep in sync, and not all of
397them have access to the \s-1WAN\s0 (so you are not able to rsync all the
398source trees to the real source), there are some ways to get around
399this problem.
400.RS 4
401.IP "Using rsync over the \s-1LAN\s0" 4
402.IX Item "Using rsync over the LAN"
403Set up a local rsync server which makes the rsynced source tree
404available to the \s-1LAN\s0 and sync the other machines against this
405directory.
406.Sp
407From http://rsync.samba.org/README.html :
408.Sp
409.Vb 5
410\& "Rsync uses rsh or ssh for communication. It does not need to be
411\& setuid and requires no special privileges for installation. It
412\& does not require an inetd entry or a daemon. You must, however,
413\& have a working rsh or ssh system. Using ssh is recommended for
414\& its security features."
415.Ve
416.IP "Using pushing over the \s-1NFS\s0" 4
417.IX Item "Using pushing over the NFS"
418Having the other systems mounted over the \s-1NFS\s0, you can take an
419active pushing approach by checking the just updated tree against
420the other not-yet synced trees. An example would be
421.Sp
422.Vb 1
423\& #!/usr/bin/perl -w
424.Ve
425.Sp
426.Vb 2
427\& use strict;
428\& use File::Copy;
429.Ve
430.Sp
431.Vb 4
432\& my %MF = map {
433\& m/(\eS+)/;
434\& $1 => [ (stat $1)[2, 7, 9] ]; # mode, size, mtime
435\& } `cat MANIFEST`;
436.Ve
437.Sp
438.Vb 1
439\& my %remote = map { $_ => "/$_/pro/3gl/CPAN/perl-5.7.1" } qw(host1 host2);
440.Ve
441.Sp
442.Vb 18
443\& foreach my $host (keys %remote) {
444\& unless (-d $remote{$host}) {
445\& print STDERR "Cannot Xsync for host $host\en";
446\& next;
447\& }
448\& foreach my $file (keys %MF) {
449\& my $rfile = "$remote{$host}/$file";
450\& my ($mode, $size, $mtime) = (stat $rfile)[2, 7, 9];
451\& defined $size or ($mode, $size, $mtime) = (0, 0, 0);
452\& $size == $MF{$file}[1] && $mtime == $MF{$file}[2] and next;
453\& printf "%4s %-34s %8d %9d %8d %9d\en",
454\& $host, $file, $MF{$file}[1], $MF{$file}[2], $size, $mtime;
455\& unlink $rfile;
456\& copy ($file, $rfile);
457\& utime time, $MF{$file}[2], $rfile;
458\& chmod $MF{$file}[0], $rfile;
459\& }
460\& }
461.Ve
462.Sp
463though this is not perfect. It could be improved with checking
464file checksums before updating. Not all \s-1NFS\s0 systems support
465reliable utime support (when used over the \s-1NFS\s0).
466.RE
467.RS 4
468.RE
469.IP "rsync'ing the patches" 4
470.IX Item "rsync'ing the patches"
471The source tree is maintained by the pumpking who applies patches to
472the files in the tree. These patches are either created by the
473pumpking himself using \f(CW\*(C`diff \-c\*(C'\fR after updating the file manually or
474by applying patches sent in by posters on the perl5\-porters list.
475These patches are also saved and rsync'able, so you can apply them
476yourself to the source files.
477.Sp
478Presuming you are in a directory where your patches reside, you can
479get them in sync with
480.Sp
481.Vb 1
482\& # rsync -avz rsync://ftp.linux.activestate.com/perl-current-diffs/ .
483.Ve
484.Sp
485This makes sure the latest available patch is downloaded to your
486patch directory.
487.Sp
488It's then up to you to apply these patches, using something like
489.Sp
490.Vb 5
491\& # last=`ls -t *.gz | sed q`
492\& # rsync -avz rsync://ftp.linux.activestate.com/perl-current-diffs/ .
493\& # find . -name '*.gz' -newer $last -exec gzcat {} \e; >blead.patch
494\& # cd ../perl-current
495\& # patch -p1 -N <../perl-current-diffs/blead.patch
496.Ve
497.Sp
498or, since this is only a hint towards how it works, use CPAN-patchaperl
499