Install Perl 5.8.8
[msysgit.git] / mingw / html / pod / perlfaq1.html
bloba4b975e1c717f3f877a0f21540ea753b46c68064
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>perlfaq1 - General Questions About Perl</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;perlfaq1 - General Questions About Perl</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#description">DESCRIPTION</a></li>
24 <ul>
26 <li><a href="#what_is_perl">What is Perl?</a></li>
27 <li><a href="#who_supports_perl_who_develops_it_why_is_it_free">Who supports Perl? Who develops it? Why is it free?</a></li>
28 <li><a href="#which_version_of_perl_should_i_use">Which version of Perl should I use?</a></li>
29 <li><a href="#what_are_perl4__perl5__or_perl6">What are perl4, perl5, or perl6?</a></li>
30 <li><a href="#what_is_ponie">What is Ponie?</a></li>
31 <li><a href="#what_is_perl6">What is perl6?</a></li>
32 <li><a href="#how_stable_is_perl">How stable is Perl?</a></li>
33 <li><a href="#is_perl_difficult_to_learn">Is Perl difficult to learn?</a></li>
34 <li><a href="#how_does_perl_compare_with_other_languages_like_java__python__rexx__scheme__or_tcl">How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?</a></li>
35 <li><a href="#can_i_do__task__in_perl">Can I do [task] in Perl?</a></li>
36 <li><a href="#when_shouldn_t_i_program_in_perl">When shouldn't I program in Perl?</a></li>
37 <li><a href="#what_s_the_difference_between_perl_and_perl">What's the difference between ``perl'' and ``Perl''?</a></li>
38 <li><a href="#is_it_a_perl_program_or_a_perl_script">Is it a Perl program or a Perl script?</a></li>
39 <li><a href="#what_is_a_japh">What is a JAPH?</a></li>
40 <li><a href="#where_can_i_get_a_list_of_larry_wall_witticisms">Where can I get a list of Larry Wall witticisms?</a></li>
41 <li><a href="#how_can_i_convince_my_sysadmin_supervisor_employees_to_use_version_5_5_6_1_perl_instead_of_some_other_language">How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language?</a></li>
42 </ul>
44 <li><a href="#author_and_copyright">AUTHOR AND COPYRIGHT</a></li>
45 </ul>
46 <!-- INDEX END -->
48 <hr />
49 <p>
50 </p>
51 <h1><a name="name">NAME</a></h1>
52 <p>perlfaq1 - General Questions About Perl ($Revision: 1.19 $, $Date: 2005/12/31 00:54:37 $)</p>
53 <p>
54 </p>
55 <hr />
56 <h1><a name="description">DESCRIPTION</a></h1>
57 <p>This section of the FAQ answers very general, high-level questions
58 about Perl.</p>
59 <p>
60 </p>
61 <h2><a name="what_is_perl">What is Perl?</a></h2>
62 <p>Perl is a high-level programming language with an eclectic heritage
63 written by Larry Wall and a cast of thousands. It derives from the
64 ubiquitous C programming language and to a lesser extent from sed,
65 awk, the Unix shell, and at least a dozen other tools and languages.
66 Perl's process, file, and text manipulation facilities make it
67 particularly well-suited for tasks involving quick prototyping, system
68 utilities, software tools, system management tasks, database access,
69 graphical programming, networking, and world wide web programming.
70 These strengths make it especially popular with system administrators
71 and CGI script authors, but mathematicians, geneticists, journalists,
72 and even managers also use Perl. Maybe you should, too.</p>
73 <p>
74 </p>
75 <h2><a name="who_supports_perl_who_develops_it_why_is_it_free">Who supports Perl? Who develops it? Why is it free?</a></h2>
76 <p>The original culture of the pre-populist Internet and the deeply-held
77 beliefs of Perl's author, Larry Wall, gave rise to the free and open
78 distribution policy of perl. Perl is supported by its users. The
79 core, the standard Perl library, the optional modules, and the
80 documentation you're reading now were all written by volunteers. See
81 the personal note at the end of the README file in the perl source
82 distribution for more details. See <a href="file://C|\msysgit\mingw\html/pod/perlhist.html">the perlhist manpage</a> (new as of 5.005)
83 for Perl's milestone releases.</p>
84 <p>In particular, the core development team (known as the Perl Porters)
85 are a rag-tag band of highly altruistic individuals committed to
86 producing better software for free than you could hope to purchase for
87 money. You may snoop on pending developments via the archives at
88 <a href="http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/">http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/</a>
89 and <a href="http://archive.develooper.com/perl5-porters@perl.org/">http://archive.develooper.com/perl5-porters@perl.org/</a>
90 or the news gateway <a href="nntp://nntp.perl.org/perl.perl5.porters">nntp://nntp.perl.org/perl.perl5.porters</a> or
91 its web interface at <a href="http://nntp.perl.org/group/perl.perl5.porters">http://nntp.perl.org/group/perl.perl5.porters</a> ,
92 or read the faq at <a href="http://simon-cozens.org/writings/p5p-faq">http://simon-cozens.org/writings/p5p-faq</a> ,
93 or you can subscribe to the mailing list by sending
94 <a href="mailto:perl5-porters-request@perl.org">perl5-porters-request@perl.org</a> a subscription request
95 (an empty message with no subject is fine).</p>
96 <p>While the GNU project includes Perl in its distributions, there's no
97 such thing as ``GNU Perl''. Perl is not produced nor maintained by the
98 Free Software Foundation. Perl's licensing terms are also more open
99 than GNU software's tend to be.</p>
100 <p>You can get commercial support of Perl if you wish, although for most
101 users the informal support will more than suffice. See the answer to
102 ``Where can I buy a commercial version of perl?'' for more information.</p>
104 </p>
105 <h2><a name="which_version_of_perl_should_i_use">Which version of Perl should I use?</a></h2>
106 <p>(contributed by brian d foy)</p>
107 <p>There is often a matter of opinion and taste, and there isn't any
108 one answer that fits anyone. In general, you want to use either
109 the current stable release, or the stable release immediately prior
110 to that one. Currently, those are perl5.8.x and perl5.6.x, respectively.</p>
111 <p>Beyond that, you have to consider several things and decide which
112 is best for you.</p>
113 <ul>
114 <li>
115 <p>If things aren't broken, upgrading perl may break
116 them (or at least issue new warnings).</p>
117 </li>
118 <li>
119 <p>The latest versions of perl have more bug fixes.</p>
120 </li>
121 <li>
122 <p>The Perl community is geared toward supporting the most
123 recent releases, so you'll have an easier time finding help for
124 those.</p>
125 </li>
126 <li>
127 <p>Versions prior to perl5.004 had serious security problems with
128 buffer overflows, and in some cases have CERT advisories (for
129 instance, <a href="http://www.cert.org/advisories/CA-1997-17.html">http://www.cert.org/advisories/CA-1997-17.html</a> ).</p>
130 </li>
131 <li>
132 <p>The latest versions are probably the least deployed and
133 widely tested, so you may want to wait a few months after their
134 release and see what problems others have if you are risk averse.</p>
135 </li>
136 <li>
137 <p>The immediate, previous releases (i.e. perl5.6.x ) are usually
138 maintained for a while, although not at the same level as the
139 current releases.</p>
140 </li>
141 <li>
142 <p>No one is actively supporting perl4.x. Five years ago it was
143 a dead camel carcass (according to this document). Now it's barely
144 a skeleton as its whitewashed bones have fractured or eroded.</p>
145 </li>
146 <li>
147 <p>There is no perl6.x for the next couple of years. Stay tuned,
148 but don't worry that you'll have to change major versions of Perl
149 soon (i.e. before 2006).</p>
150 </li>
151 <li>
152 <p>There are really two tracks of perl development: a
153 maintenance version and an experimental version. The
154 maintenance versions are stable, and have an even number
155 as the minor release (i.e. perl5.8.x, where 8 is the minor
156 release). The experimental versions may include features that
157 don't make it into the stable versions, and have an odd number
158 as the minor release (i.e. perl5.9.x, where 9 is the minor release).</p>
159 </li>
160 </ul>
162 </p>
163 <h2><a name="what_are_perl4__perl5__or_perl6">What are perl4, perl5, or perl6?</a></h2>
164 <p>(contributed by brian d foy)</p>
165 <p>In short, perl4 is the past, perl5 is the present, and perl6 is the
166 future.</p>
167 <p>The number after perl (i.e. the 5 after perl5) is the major release
168 of the perl interpreter as well as the version of the language. Each
169 major version has significant differences that earlier versions cannot
170 support.</p>
171 <p>The current major release of Perl is perl5, and was released in 1994.
172 It can run scripts from the previous major release, perl4 (March 1991),
173 but has significant differences. It introduced the concept of references,
174 complex data structures, and modules. The perl5 interpreter was a
175 complete re-write of the previous perl sources.</p>
176 <p>Perl6 is the next major version of Perl, but it's still in development
177 in both its syntax and design. The work started in 2002 and is still
178 ongoing. Many of the most interesting features have shown up in the
179 latest versions of perl5, and some perl5 modules allow you to use some
180 perl6 syntax in your programs. You can learn more about perl6 at
181 <a href="http://dev.perl.org/perl6/">http://dev.perl.org/perl6/</a> .</p>
182 <p>See <a href="file://C|\msysgit\mingw\html/pod/perlhist.html">the perlhist manpage</a> for a history of Perl revisions.</p>
184 </p>
185 <h2><a name="what_is_ponie">What is Ponie?</a></h2>
186 <p>At The O'Reilly Open Source Software Convention in 2003, Artur
187 Bergman, Fotango, and The Perl Foundation announced a project to
188 run perl5 on the Parrot virtual machine named Ponie. Ponie stands for
189 Perl On New Internal Engine. The Perl 5.10 language implementation
190 will be used for Ponie, and there will be no language level
191 differences between perl5 and ponie. Ponie is not a complete rewrite
192 of perl5.</p>
193 <p>For more details, see <a href="http://www.poniecode.org/">http://www.poniecode.org/</a></p>
195 </p>
196 <h2><a name="what_is_perl6">What is perl6?</a></h2>
197 <p>At The Second O'Reilly Open Source Software Convention, Larry Wall
198 announced Perl6 development would begin in earnest. Perl6 was an oft
199 used term for Chip Salzenberg's project to rewrite Perl in C++ named
200 Topaz. However, Topaz provided valuable insights to the next version
201 of Perl and its implementation, but was ultimately abandoned.</p>
202 <p>If you want to learn more about Perl6, or have a desire to help in
203 the crusade to make Perl a better place then peruse the Perl6 developers
204 page at <a href="http://dev.perl.org/perl6/">http://dev.perl.org/perl6/</a> and get involved.</p>
205 <p>Perl6 is not scheduled for release yet, and Perl5 will still be supported
206 for quite awhile after its release. Do not wait for Perl6 to do whatever
207 you need to do.</p>
208 <p>``We're really serious about reinventing everything that needs reinventing.''
209 --Larry Wall</p>
211 </p>
212 <h2><a name="how_stable_is_perl">How stable is Perl?</a></h2>
213 <p>Production releases, which incorporate bug fixes and new functionality,
214 are widely tested before release. Since the 5.000 release, we have
215 averaged only about one production release per year.</p>
216 <p>Larry and the Perl development team occasionally make changes to the
217 internal core of the language, but all possible efforts are made toward
218 backward compatibility. While not quite all perl4 scripts run flawlessly
219 under perl5, an update to perl should nearly never invalidate a program
220 written for an earlier version of perl (barring accidental bug fixes
221 and the rare new keyword).</p>
223 </p>
224 <h2><a name="is_perl_difficult_to_learn">Is Perl difficult to learn?</a></h2>
225 <p>No, Perl is easy to start learning--and easy to keep learning. It looks
226 like most programming languages you're likely to have experience
227 with, so if you've ever written a C program, an awk script, a shell
228 script, or even a BASIC program, you're already partway there.</p>
229 <p>Most tasks only require a small subset of the Perl language. One of
230 the guiding mottos for Perl development is ``there's more than one way
231 to do it'' (TMTOWTDI, sometimes pronounced ``tim toady''). Perl's
232 learning curve is therefore shallow (easy to learn) and long (there's
233 a whole lot you can do if you really want).</p>
234 <p>Finally, because Perl is frequently (but not always, and certainly not by
235 definition) an interpreted language, you can write your programs and test
236 them without an intermediate compilation step, allowing you to experiment
237 and test/debug quickly and easily. This ease of experimentation flattens
238 the learning curve even more.</p>
239 <p>Things that make Perl easier to learn: Unix experience, almost any kind
240 of programming experience, an understanding of regular expressions, and
241 the ability to understand other people's code. If there's something you
242 need to do, then it's probably already been done, and a working example is
243 usually available for free. Don't forget the new perl modules, either.
244 They're discussed in Part 3 of this FAQ, along with CPAN, which is
245 discussed in Part 2.</p>
247 </p>
248 <h2><a name="how_does_perl_compare_with_other_languages_like_java__python__rexx__scheme__or_tcl">How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?</a></h2>
249 <p>Favorably in some areas, unfavorably in others. Precisely which areas
250 are good and bad is often a personal choice, so asking this question
251 on Usenet runs a strong risk of starting an unproductive Holy War.</p>
252 <p>Probably the best thing to do is try to write equivalent code to do a
253 set of tasks. These languages have their own newsgroups in which you
254 can learn about (but hopefully not argue about) them.</p>
255 <p>Some comparison documents can be found at <a href="http://www.perl.com/doc/FMTEYEWTK/versus/">http://www.perl.com/doc/FMTEYEWTK/versus/</a>
256 if you really can't stop yourself.</p>
258 </p>
259 <h2><a name="can_i_do__task__in_perl">Can I do [task] in Perl?</a></h2>
260 <p>Perl is flexible and extensible enough for you to use on virtually any
261 task, from one-line file-processing tasks to large, elaborate systems.
262 For many people, Perl serves as a great replacement for shell scripting.
263 For others, it serves as a convenient, high-level replacement for most of
264 what they'd program in low-level languages like C or C++. It's ultimately
265 up to you (and possibly your management) which tasks you'll use Perl
266 for and which you won't.</p>
267 <p>If you have a library that provides an API, you can make any component
268 of it available as just another Perl function or variable using a Perl
269 extension written in C or C++ and dynamically linked into your main
270 perl interpreter. You can also go the other direction, and write your
271 main program in C or C++, and then link in some Perl code on the fly,
272 to create a powerful application. See <a href="file://C|\msysgit\mingw\html/pod/perlembed.html">the perlembed manpage</a>.</p>
273 <p>That said, there will always be small, focused, special-purpose
274 languages dedicated to a specific problem domain that are simply more
275 convenient for certain kinds of problems. Perl tries to be all things
276 to all people, but nothing special to anyone. Examples of specialized
277 languages that come to mind include prolog and matlab.</p>
279 </p>
280 <h2><a name="when_shouldn_t_i_program_in_perl">When shouldn't I program in Perl?</a></h2>
281 <p>When your manager forbids it--but do consider replacing them :-).</p>
282 <p>Actually, one good reason is when you already have an existing
283 application written in another language that's all done (and done
284 well), or you have an application language specifically designed for a
285 certain task (e.g. prolog, make).</p>
286 <p>For various reasons, Perl is probably not well-suited for real-time
287 embedded systems, low-level operating systems development work like
288 device drivers or context-switching code, complex multi-threaded
289 shared-memory applications, or extremely large applications. You'll
290 notice that perl is not itself written in Perl.</p>
291 <p>The new, native-code compiler for Perl may eventually reduce the
292 limitations given in the previous statement to some degree, but understand
293 that Perl remains fundamentally a dynamically typed language, not
294 a statically typed one. You certainly won't be chastised if you don't
295 trust nuclear-plant or brain-surgery monitoring code to it. And Larry
296 will sleep easier, too--Wall Street programs not withstanding. :-)</p>
298 </p>
299 <h2><a name="what_s_the_difference_between_perl_and_perl">What's the difference between ``perl'' and ``Perl''?</a></h2>
300 <p>One bit. Oh, you weren't talking ASCII? :-) Larry now uses ``Perl'' to
301 signify the language proper and ``perl'' the implementation of it,
302 i.e. the current interpreter. Hence Tom's quip that ``Nothing but perl
303 can parse Perl.'' You may or may not choose to follow this usage. For
304 example, parallelism means ``awk and perl'' and ``Python and Perl'' look
305 OK, while ``awk and Perl'' and ``Python and perl'' do not. But never
306 write ``PERL'', because perl is not an acronym, apocryphal
307 folklore and post-facto expansions notwithstanding.</p>
309 </p>
310 <h2><a name="is_it_a_perl_program_or_a_perl_script">Is it a Perl program or a Perl script?</a></h2>
311 <p>Larry doesn't really care. He says (half in jest) that ``a script is
312 what you give the actors. A program is what you give the audience.''</p>
313 <p>Originally, a script was a canned sequence of normally interactive
314 commands--that is, a chat script. Something like a UUCP or PPP chat
315 script or an expect script fits the bill nicely, as do configuration
316 scripts run by a program at its start up, such <em>.cshrc</em> or <em>.ircrc</em>,
317 for example. Chat scripts were just drivers for existing programs,
318 not stand-alone programs in their own right.</p>
319 <p>A computer scientist will correctly explain that all programs are
320 interpreted and that the only question is at what level. But if you
321 ask this question of someone who isn't a computer scientist, they might
322 tell you that a <em>program</em> has been compiled to physical machine code
323 once and can then be run multiple times, whereas a <em>script</em> must be
324 translated by a program each time it's used.</p>
325 <p>Perl programs are (usually) neither strictly compiled nor strictly
326 interpreted. They can be compiled to a byte-code form (something of a
327 Perl virtual machine) or to completely different languages, like C or
328 assembly language. You can't tell just by looking at it whether the
329 source is destined for a pure interpreter, a parse-tree interpreter,
330 a byte-code interpreter, or a native-code compiler, so it's hard to give
331 a definitive answer here.</p>
332 <p>Now that ``script'' and ``scripting'' are terms that have been seized by
333 unscrupulous or unknowing marketeers for their own nefarious purposes,
334 they have begun to take on strange and often pejorative meanings,
335 like ``non serious'' or ``not real programming''. Consequently, some Perl
336 programmers prefer to avoid them altogether.</p>
338 </p>
339 <h2><a name="what_is_a_japh">What is a JAPH?</a></h2>
340 <p>These are the ``just another perl hacker'' signatures that some people
341 sign their postings with. Randal Schwartz made these famous. About
342 100 of the earlier ones are available from
343 <a href="http://www.cpan.org/misc/japh">http://www.cpan.org/misc/japh</a> .</p>
345 </p>
346 <h2><a name="where_can_i_get_a_list_of_larry_wall_witticisms">Where can I get a list of Larry Wall witticisms?</a></h2>
347 <p>Over a hundred quips by Larry, from postings of his or source code,
348 can be found at <a href="http://www.cpan.org/misc/lwall-quotes.txt.gz">http://www.cpan.org/misc/lwall-quotes.txt.gz</a> .</p>
350 </p>
351 <h2><a name="how_can_i_convince_my_sysadmin_supervisor_employees_to_use_version_5_5_6_1_perl_instead_of_some_other_language">How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language?</a></h2>
352 <p>If your manager or employees are wary of unsupported software, or
353 software which doesn't officially ship with your operating system, you
354 might try to appeal to their self-interest. If programmers can be
355 more productive using and utilizing Perl constructs, functionality,
356 simplicity, and power, then the typical manager/supervisor/employee
357 may be persuaded. Regarding using Perl in general, it's also
358 sometimes helpful to point out that delivery times may be reduced
359 using Perl compared to other languages.</p>
360 <p>If you have a project which has a bottleneck, especially in terms of
361 translation or testing, Perl almost certainly will provide a viable,
362 quick solution. In conjunction with any persuasion effort, you
363 should not fail to point out that Perl is used, quite extensively, and
364 with extremely reliable and valuable results, at many large computer
365 software and hardware companies throughout the world. In fact,
366 many Unix vendors now ship Perl by default. Support is usually
367 just a news-posting away, if you can't find the answer in the
368 <em>comprehensive</em> documentation, including this FAQ.</p>
369 <p>See <a href="http://www.perl.org/advocacy/">http://www.perl.org/advocacy/</a> for more information.</p>
370 <p>If you face reluctance to upgrading from an older version of perl,
371 then point out that version 4 is utterly unmaintained and unsupported
372 by the Perl Development Team. Another big sell for Perl5 is the large
373 number of modules and extensions which greatly reduce development time
374 for any given task. Also mention that the difference between version
375 4 and version 5 of Perl is like the difference between awk and C++.
376 (Well, OK, maybe it's not quite that distinct, but you get the idea.)
377 If you want support and a reasonable guarantee that what you're
378 developing will continue to work in the future, then you have to run
379 the supported version. As of December 2003 that means running either
380 5.8.2 (released in November 2003), or one of the older releases like
381 5.6.2 (also released in November 2003; a maintenance release to let perl
382 5.6 compile on newer systems as 5.6.1 was released in April 2001) or
383 5.005_03 (released in March 1999),
384 although 5.004_05 isn't that bad if you <strong>absolutely</strong> need such an old
385 version (released in April 1999) for stability reasons.
386 Anything older than 5.004_05 shouldn't be used.</p>
387 <p>Of particular note is the massive bug hunt for buffer overflow
388 problems that went into the 5.004 release. All releases prior to
389 that, including perl4, are considered insecure and should be upgraded
390 as soon as possible.</p>
391 <p>In August 2000 in all Linux distributions a new security problem was
392 found in the optional 'suidperl' (not built or installed by default)
393 in all the Perl branches 5.6, 5.005, and 5.004, see
394 <a href="http://www.cpan.org/src/5.0/sperl-2000-08-05/">http://www.cpan.org/src/5.0/sperl-2000-08-05/</a>
395 Perl maintenance releases 5.6.1 and 5.8.0 have this security hole closed.
396 Most, if not all, Linux distribution have patches for this
397 vulnerability available, see <a href="http://www.linuxsecurity.com/advisories/">http://www.linuxsecurity.com/advisories/</a> ,
398 but the most recommendable way is to upgrade to at least Perl 5.6.1.</p>
400 </p>
401 <hr />
402 <h1><a name="author_and_copyright">AUTHOR AND COPYRIGHT</a></h1>
403 <p>Copyright (c) 1997-2006 Tom Christiansen, Nathan Torkington, and
404 other authors as noted. All rights reserved.</p>
405 <p>This documentation is free; you can redistribute it and/or modify it
406 under the same terms as Perl itself.</p>
407 <p>Irrespective of its distribution, all code examples here are in the public
408 domain. You are permitted and encouraged to use this code and any
409 derivatives thereof in your own programs for fun or for profit as you
410 see fit. A simple comment in the code giving credit to the FAQ would
411 be courteous but is not required.</p>
412 <table border="0" width="100%" cellspacing="0" cellpadding="3">
413 <tr><td class="block" style="background-color: #cccccc" valign="middle">
414 <big><strong><span class="block">&nbsp;perlfaq1 - General Questions About Perl</span></strong></big>
415 </td></tr>
416 </table>
418 </body>
420 </html>