source: for-distributions/trunk/bin/windows/perl/lib/Pod/perlfaq1.pod@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

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