Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man1 / perlfaq1.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 "PERLFAQ1 1"
132.TH PERLFAQ1 1 "2002-06-08" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134perlfaq1 \- General Questions About Perl ($Revision: 1.8 $, $Date: 2002/04/07 18:46:13 $)
135.SH "DESCRIPTION"
136.IX Header "DESCRIPTION"
137This section of the \s-1FAQ\s0 answers very general, high-level questions
138about Perl.
139.Sh "What is Perl?"
140.IX Subsection "What is Perl?"
141Perl is a high-level programming language with an eclectic heritage
142written by Larry Wall and a cast of thousands. It derives from the
143ubiquitous C programming language and to a lesser extent from sed,
144awk, the Unix shell, and at least a dozen other tools and languages.
145Perl's process, file, and text manipulation facilities make it
146particularly well-suited for tasks involving quick prototyping, system
147utilities, software tools, system management tasks, database access,
148graphical programming, networking, and world wide web programming.
149These strengths make it especially popular with system administrators
150and \s-1CGI\s0 script authors, but mathematicians, geneticists, journalists,
151and even managers also use Perl. Maybe you should, too.
152.Sh "Who supports Perl? Who develops it? Why is it free?"
153.IX Subsection "Who supports Perl? Who develops it? Why is it free?"
154The original culture of the pre-populist Internet and the deeply-held
155beliefs of Perl's author, Larry Wall, gave rise to the free and open
156distribution policy of perl. Perl is supported by its users. The
157core, the standard Perl library, the optional modules, and the
158documentation you're reading now were all written by volunteers. See
159the personal note at the end of the \s-1README\s0 file in the perl source
160distribution for more details. See perlhist (new as of 5.005)
161for Perl's milestone releases.
162.PP
163In particular, the core development team (known as the Perl Porters)
164are a rag-tag band of highly altruistic individuals committed to
165producing better software for free than you could hope to purchase for
166money. You may snoop on pending developments via the archives at
167http://www.xray.mpe.mpg.de/mailing\-lists/perl5\-porters/
168and http://archive.develooper.com/perl5\-porters@perl.org/
169or the news gateway nntp://nntp.perl.org/perl.perl5.porters or
170its web interface at http://nntp.perl.org/group/perl.perl5.porters ,
171or read the faq at http://perlhacker.org/p5p\-faq ,
172or you can subscribe to the mailing list by sending
173perl5\-porters\-request@perl.org a subscription request
174(an empty message with no subject is fine).
175.PP
176While the \s-1GNU\s0 project includes Perl in its distributions, there's no
177such thing as \*(L"\s-1GNU\s0 Perl\*(R". Perl is not produced nor maintained by the
178Free Software Foundation. Perl's licensing terms are also more open
179than \s-1GNU\s0 software's tend to be.
180.PP
181You can get commercial support of Perl if you wish, although for most
182users the informal support will more than suffice. See the answer to
183\&\*(L"Where can I buy a commercial version of perl?\*(R" for more information.
184.Sh "Which version of Perl should I use?"
185.IX Subsection "Which version of Perl should I use?"
186You should definitely use version 5. Version 4 is old, limited, and
187no longer maintained; its last patch (4.036) was in 1992, long ago and
188far away. Sure, it's stable, but so is anything that's dead; in fact,
189perl4 had been called a dead, flea-bitten camel carcass. The most recent
190production release is 5.6 (although 5.005_03 is still supported).
191The most cutting-edge development release is 5.7. Further references
192to the Perl language in this document refer to the production release
193unless otherwise specified. There may be one or more official bug fixes
194by the time you read this, and also perhaps some experimental versions
195on the way to the next release. All releases prior to 5.004 were subject
196to buffer overruns, a grave security issue.
197.Sh "What are perl4 and perl5?"
198.IX Subsection "What are perl4 and perl5?"
199Perl4 and perl5 are informal names for different versions of the Perl
200programming language. It's easier to say \*(L"perl5\*(R" than it is to say
201\&\*(L"the 5(.004) release of Perl\*(R", but some people have interpreted this
202to mean there's a language called \*(L"perl5\*(R", which isn't the case.
203Perl5 is merely the popular name for the fifth major release (October 1994),
204while perl4 was the fourth major release (March 1991). There was also a
205perl1 (in January 1988), a perl2 (June 1988), and a perl3 (October 1989).
206.PP
207The 5.0 release is, essentially, a ground-up rewrite of the original
208perl source code from releases 1 through 4. It has been modularized,
209object\-oriented, tweaked, trimmed, and optimized until it almost doesn't
210look like the old code. However, the interface is mostly the same, and
211compatibility with previous releases is very high.
212See \*(L"Perl4 to Perl5 Traps\*(R" in perltrap.
213.PP
214To avoid the \*(L"what language is perl5?\*(R" confusion, some people prefer to
215simply use \*(L"perl\*(R" to refer to the latest version of perl and avoid using
216\&\*(L"perl5\*(R" altogether. It's not really that big a deal, though.
217.PP
218See perlhist for a history of Perl revisions.
219.Sh "What is perl6?"
220.IX Subsection "What is perl6?"
221At The Second O'Reilly Open Source Software Convention, Larry Wall
222announced Perl6 development would begin in earnest. Perl6 was an oft
223used term for Chip Salzenberg's project to rewrite Perl in \*(C+ named
224Topaz. However, Topaz provided valuable insights to the next version
225of Perl and its implementation, but was ultimately abandoned.
226.PP
227If you want to learn more about Perl6, or have a desire to help in
228the crusade to make Perl a better place then peruse the Perl6 developers
229page at http://dev.perl.org/perl6/ and get involved.
230.PP
231Perl6 is not scheduled for release yet, and Perl5 will still be supported
232for quite awhile after its release. Do not wait for Perl6 to do whatever
233you need to do.
234.PP
235\&\*(L"We're really serious about reinventing everything that needs reinventing.\*(R"
236\&\-\-Larry Wall
237.Sh "How stable is Perl?"
238.IX Subsection "How stable is Perl?"
239Production releases, which incorporate bug fixes and new functionality,
240are widely tested before release. Since the 5.000 release, we have
241averaged only about one production release per year.
242.PP
243Larry and the Perl development team occasionally make changes to the
244internal core of the language, but all possible efforts are made toward
245backward compatibility. While not quite all perl4 scripts run flawlessly
246under perl5, an update to perl should nearly never invalidate a program
247written for an earlier version of perl (barring accidental bug fixes
248and the rare new keyword).
249.Sh "Is Perl difficult to learn?"
250.IX Subsection "Is Perl difficult to learn?"
251No, Perl is easy to start learning\*(--and easy to keep learning. It looks
252like most programming languages you're likely to have experience
253with, so if you've ever written a C program, an awk script, a shell
254script, or even a \s-1BASIC\s0 program, you're already partway there.
255.PP
256Most tasks only require a small subset of the Perl language. One of
257the guiding mottos for Perl development is \*(L"there's more than one way
258to do it\*(R" (\s-1TMTOWTDI\s0, sometimes pronounced \*(L"tim toady\*(R"). Perl's
259learning curve is therefore shallow (easy to learn) and long (there's
260a whole lot you can do if you really want).
261.PP
262Finally, because Perl is frequently (but not always, and certainly not by
263definition) an interpreted language, you can write your programs and test
264them without an intermediate compilation step, allowing you to experiment
265and test/debug quickly and easily. This ease of experimentation flattens
266the learning curve even more.
267.PP
268Things that make Perl easier to learn: Unix experience, almost any kind
269of programming experience, an understanding of regular expressions, and
270the ability to understand other people's code. If there's something you
271need to do, then it's probably already been done, and a working example is
272usually available for free. Don't forget the new perl modules, either.
273They're discussed in Part 3 of this \s-1FAQ\s0, along with \s-1CPAN\s0, which is
274discussed in Part 2.
275.Sh "How does Perl compare with other languages like Java, Python, \s-1REXX\s0, Scheme, or Tcl?"
276.IX Subsection "How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?"
277Favorably in some areas, unfavorably in others. Precisely which areas
278are good and bad is often a personal choice, so asking this question
279on Usenet runs a strong risk of starting an unproductive Holy War.
280.PP
281Probably the best thing to do is try to write equivalent code to do a
282set of tasks. These languages have their own newsgroups in which you
283can learn about (but hopefully not argue about) them.
284.PP
285Some comparison documents can be found at http://language.perl.com/versus/
286if you really can't stop yourself.
287.Sh "Can I do [task] in Perl?"
288.IX Subsection "Can I do [task] in Perl?"
289Perl is flexible and extensible enough for you to use on virtually any
290task, from one-line file-processing tasks to large, elaborate systems.
291For many people, Perl serves as a great replacement for shell scripting.
292For others, it serves as a convenient, high-level replacement for most of
293what they'd program in low-level languages like C or \*(C+. It's ultimately
294up to you (and possibly your management) which tasks you'll use Perl
295for and which you won't.
296.PP
297If you have a library that provides an \s-1API\s0, you can make any component
298of it available as just another Perl function or variable using a Perl
299extension written in C or \*(C+ and dynamically linked into your main
300perl interpreter. You can also go the other direction, and write your
301main program in C or \*(C+, and then link in some Perl code on the fly,
302to create a powerful application. See perlembed.
303.PP
304That said, there will always be small, focused, special-purpose
305languages dedicated to a specific problem domain that are simply more
306convenient for certain kinds of problems. Perl tries to be all things
307to all people, but nothing special to anyone. Examples of specialized
308languages that come to mind include prolog and matlab.
309.Sh "When shouldn't I program in Perl?"
310.IX Subsection "When shouldn't I program in Perl?"
311When your manager forbids it\*(--but do consider replacing them :\-).
312.PP
313Actually, one good reason is when you already have an existing
314application written in another language that's all done (and done
315well), or you have an application language specifically designed for a
316certain task (e.g. prolog, make).
317.PP
318For various reasons, Perl is probably not well-suited for real-time
319embedded systems, low-level operating systems development work like
320device drivers or context-switching code, complex multi-threaded
321shared-memory applications, or extremely large applications. You'll
322notice that perl is not itself written in Perl.
323.PP
324The new, native-code compiler for Perl may eventually reduce the
325limitations given in the previous statement to some degree, but understand
326that Perl remains fundamentally a dynamically typed language, not
327a statically typed one. You certainly won't be chastised if you don't
328trust nuclear-plant or brain-surgery monitoring code to it. And Larry
329will sleep easier, too\*(--Wall Street programs not withstanding. :\-)
330.ie n .Sh "What's the difference between ""perl"" and ""Perl""?"
331.el .Sh "What's the difference between ``perl'' and ``Perl''?"
332.IX Subsection "What's the difference between perl and Perl?"
333One bit. Oh, you weren't talking \s-1ASCII\s0? :\-) Larry now uses \*(L"Perl\*(R" to
334signify the language proper and \*(L"perl\*(R" the implementation of it,
335i.e. the current interpreter. Hence Tom's quip that \*(L"Nothing but perl
336can parse Perl.\*(R" You may or may not choose to follow this usage. For
337example, parallelism means \*(L"awk and perl\*(R" and \*(L"Python and Perl\*(R" look
338\&\s-1OK\s0, while \*(L"awk and Perl\*(R" and \*(L"Python and perl\*(R" do not. But never
339write \*(L"\s-1PERL\s0\*(R", because perl is not an acronym, apocryphal
340folklore and post-facto expansions notwithstanding.
341.Sh "Is it a Perl program or a Perl script?"
342.IX Subsection "Is it a Perl program or a Perl script?"
343Larry doesn't really care. He says (half in jest) that \*(L"a script is
344what you give the actors. A program is what you give the audience.\*(R"
345.PP
346Originally, a script was a canned sequence of normally interactive
347commands\*(--that is, a chat script. Something like a \s-1UUCP\s0 or \s-1PPP\s0 chat
348script or an expect script fits the bill nicely, as do configuration
349scripts run by a program at its start up, such \fI.cshrc\fR or \fI.ircrc\fR,
350for example. Chat scripts were just drivers for existing programs,
351not stand-alone programs in their own right.
352.PP
353A computer scientist will correctly explain that all programs are
354interpreted and that the only question is at what level. But if you
355ask this question of someone who isn't a computer scientist, they might
356tell you that a \fIprogram\fR has been compiled to physical machine code
357once and can then be run multiple times, whereas a \fIscript\fR must be
358translated by a program each time it's used.
359.PP
360Perl programs are (usually) neither strictly compiled nor strictly
361interpreted. They can be compiled to a byte-code form (something of a
362Perl virtual machine) or to completely different languages, like C or
363assembly language. You can't tell just by looking at it whether the
364source is destined for a pure interpreter, a parse-tree interpreter,
365a byte-code interpreter, or a native-code compiler, so it's hard to give
366a definitive answer here.
367.PP
368Now that \*(L"script\*(R" and \*(L"scripting\*(R" are terms that have been seized by
369unscrupulous or unknowing marketeers for their own nefarious purposes,
370they have begun to take on strange and often pejorative meanings,
371like \*(L"non serious\*(R" or \*(L"not real programming\*(R". Consequently, some Perl
372programmers prefer to avoid them altogether.
373.Sh "What is a \s-1JAPH\s0?"
374.IX Subsection "What is a JAPH?"
375These are the \*(L"just another perl hacker\*(R" signatures that some people
376sign their postings with. Randal Schwartz made these famous. About
377100 of the earlier ones are available from
378http://www.cpan.org/misc/japh .
379.Sh "Where can I get a list of Larry Wall witticisms?"
380.IX Subsection "Where can I get a list of Larry Wall witticisms?"
381Over a hundred quips by Larry, from postings of his or source code,
382can be found at http://www.cpan.org/misc/lwall\-quotes.txt.gz .
383.Sh "How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language?"
384.IX Subsection "How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language?"
385If your manager or employees are wary of unsupported software, or
386software which doesn't officially ship with your operating system, you
387might try to appeal to their self\-interest. If programmers can be
388more productive using and utilizing Perl constructs, functionality,
389simplicity, and power, then the typical manager/supervisor/employee
390may be persuaded. Regarding using Perl in general, it's also
391sometimes helpful to point out that delivery times may be reduced
392using Perl compared to other languages.
393.PP
394If you have a project which has a bottleneck, especially in terms of
395translation or testing, Perl almost certainly will provide a viable,
396quick solution. In conjunction with any persuasion effort, you
397should not fail to point out that Perl is used, quite extensively, and
398with extremely reliable and valuable results, at many large computer
399software and hardware companies throughout the world. In fact,
400many Unix vendors now ship Perl by default. Support is usually
401just a news-posting away, if you can't find the answer in the
402\&\fIcomprehensive\fR documentation, including this \s-1FAQ\s0.
403.PP
404See http://www.perl.org/advocacy/ for more information.
405.PP
406If you face reluctance to upgrading from an older version of perl,
407then point out that version 4 is utterly unmaintained and unsupported
408by the Perl Development Team. Another big sell for Perl5 is the large
409number of modules and extensions which greatly reduce development time
410for any given task. Also mention that the difference between version
4114 and version 5 of Perl is like the difference between awk and \*(C+.
412(Well, \s-1OK\s0, maybe it's not quite that distinct, but you get the idea.)
413If you want support and a reasonable guarantee that what you're
414developing will continue to work in the future, then you have to run
415the supported version. As of January 2002 that probably means
416running either of the releases 5.6.1 (released in April 2001) or
4175.005_03 (released in March 1999), although 5.004_05 isn't that bad
418if you \fBabsolutely\fR need such an old version (released in April 1999)
419for stability reasons. Anything older than 5.004_05 shouldn't be used.
420.PP
421Of particular note is the massive bug hunt for buffer overflow
422problems that went into the 5.004 release. All releases prior to
423that, including perl4, are considered insecure and should be upgraded
424as soon as possible.
425.PP
426In August 2000 in all Linux distributions a new security problem was
427found in the optional 'suidperl' (not built or installed by default)
428in all the Perl branches 5.6, 5.005, and 5.004, see
429http://www.cpan.org/src/5.0/sperl\-2000\-08\-05/
430Perl maintenance releases 5.6.1 and 5.8.0 have this security hole closed.
431Most, if not all, Linux distribution have patches for this
432vulnerability available, see http://www.linuxsecurity.com/advisories/ ,
433but the most recommendable way is to upgrade to at least Perl 5.6.1.
434.SH "AUTHOR AND COPYRIGHT"
435.IX Header "AUTHOR AND COPYRIGHT"
436Copyright (c) 1997, 1998, 1999, 2000, 2001 Tom Christiansen and Nathan
437Torkington. All rights reserved.
438.PP
439This documentation is free; you can redistribute it and/or modify it
440under the same terms as Perl itself.
441.PP
442Irrespective of its distribution, all code examples here are in the public
443domain. You are permitted and encouraged to use this code and any
444derivatives thereof in your own programs for fun or for profit as you
445see fit. A simple comment in the code giving credit to the \s-1FAQ\s0 would
446be courteous but is not required.