-x should be C<-x>, reported by Gerben Wierda.
[p5sagit/p5-mst-13.2.git] / pod / perlfaq1.pod
CommitLineData
68dc0745 1=head1 NAME
2
5e3006a4 3perlfaq1 - General Questions About Perl ($Revision: 1.15 $, $Date: 1998/08/05 11:52:24 $)
68dc0745 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
5e3006a4 32distribution for more details. See L<perlhist> (new as of 5.005)
33for Perl's milestone releases.
68dc0745 34
35In particular, the core development team (known as the Perl
36Porters) are a rag-tag band of highly altruistic individuals
37committed to producing better software for free than you
38could hope to purchase for money. You may snoop on pending
bd3fa61c 39developments via news://news.perl.com/perl.porters-gw/ and
68dc0745 40http://www.frii.com/~gnat/perl/porters/summary.html.
41
42While the GNU project includes Perl in its distributions, there's no
43such thing as "GNU Perl". Perl is not produced nor maintained by the
44Free Software Foundation. Perl's licensing terms are also more open
45than GNU software's tend to be.
46
47You can get commercial support of Perl if you wish, although for most
48users the informal support will more than suffice. See the answer to
49"Where can I buy a commercial version of perl?" for more information.
50
51=head2 Which version of Perl should I use?
52
53You should definitely use version 5. Version 4 is old, limited, and
c90c0ff4 54no longer maintained; its last patch (4.036) was in 1992. The most
5e3006a4 55recent production release is 5.005_01. Further references to the Perl
c90c0ff4 56language in this document refer to this production release unless
57otherwise specified. There may be one or more official bug fixes for
5e3006a4 585.005_01 by the time you read this, and also perhaps some experimental
c90c0ff4 59versions on the way to the next release.
68dc0745 60
61=head2 What are perl4 and perl5?
62
63Perl4 and perl5 are informal names for different versions of the Perl
64programming language. It's easier to say "perl5" than it is to say
65"the 5(.004) release of Perl", but some people have interpreted this
66to mean there's a language called "perl5", which isn't the case.
67Perl5 is merely the popular name for the fifth major release (October 1994),
68while perl4 was the fourth major release (March 1991). There was also a
69perl1 (in January 1988), a perl2 (June 1988), and a perl3 (October 1989).
70
71The 5.0 release is, essentially, a complete rewrite of the perl source
72code from the ground up. It has been modularized, object-oriented,
73tweaked, trimmed, and optimized until it almost doesn't look like the
74old code. However, the interface is mostly the same, and compatibility
75with previous releases is very high.
76
77To avoid the "what language is perl5?" confusion, some people prefer to
78simply use "perl" to refer to the latest version of perl and avoid using
79"perl5" altogether. It's not really that big a deal, though.
80
5a964f20 81See L<perlhist> for a history of Perl revisions.
82
68dc0745 83=head2 How stable is Perl?
84
85Production releases, which incorporate bug fixes and new functionality,
86are widely tested before release. Since the 5.000 release, we have
87averaged only about one production release per year.
88
89Larry and the Perl development team occasionally make changes to the
90internal core of the language, but all possible efforts are made toward
91backward compatibility. While not quite all perl4 scripts run flawlessly
92under perl5, an update to perl should nearly never invalidate a program
93written for an earlier version of perl (barring accidental bug fixes
94and the rare new keyword).
95
96=head2 Is Perl difficult to learn?
97
5a964f20 98No, Perl is easy to start learning -- and easy to keep learning. It looks
99like most programming languages you're likely to have experience
68dc0745 100with, so if you've ever written an C program, an awk script, a shell
5a964f20 101script, or even BASIC program, you're already part way there.
68dc0745 102
103Most tasks only require a small subset of the Perl language. One of
104the guiding mottos for Perl development is "there's more than one way
105to do it" (TMTOWTDI, sometimes pronounced "tim toady"). Perl's
106learning curve is therefore shallow (easy to learn) and long (there's
107a whole lot you can do if you really want).
108
109Finally, Perl is (frequently) an interpreted language. This means
110that you can write your programs and test them without an intermediate
111compilation step, allowing you to experiment and test/debug quickly
112and easily. This ease of experimentation flattens the learning curve
113even more.
114
115Things that make Perl easier to learn: Unix experience, almost any kind
116of programming experience, an understanding of regular expressions, and
117the ability to understand other people's code. If there's something you
118need to do, then it's probably already been done, and a working example is
119usually available for free. Don't forget the new perl modules, either.
120They're discussed in Part 3 of this FAQ, along with the CPAN, which is
121discussed in Part 2.
122
123=head2 How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
124
125Favorably in some areas, unfavorably in others. Precisely which areas
126are good and bad is often a personal choice, so asking this question
127on Usenet runs a strong risk of starting an unproductive Holy War.
128
129Probably the best thing to do is try to write equivalent code to do a
130set of tasks. These languages have their own newsgroups in which you
131can learn about (but hopefully not argue about) them.
132
133=head2 Can I do [task] in Perl?
134
135Perl is flexible and extensible enough for you to use on almost any
136task, from one-line file-processing tasks to complex systems. For
137many people, Perl serves as a great replacement for shell scripting.
138For others, it serves as a convenient, high-level replacement for most
139of what they'd program in low-level languages like C or C++. It's
140ultimately up to you (and possibly your management ...) which tasks
141you'll use Perl for and which you won't.
142
143If you have a library that provides an API, you can make any component
144of it available as just another Perl function or variable using a Perl
145extension written in C or C++ and dynamically linked into your main
146perl interpreter. You can also go the other direction, and write your
147main program in C or C++, and then link in some Perl code on the fly,
148to create a powerful application.
149
150That said, there will always be small, focused, special-purpose
151languages dedicated to a specific problem domain that are simply more
152convenient for certain kinds of problems. Perl tries to be all things
153to all people, but nothing special to anyone. Examples of specialized
154languages that come to mind include prolog and matlab.
155
156=head2 When shouldn't I program in Perl?
157
158When your manager forbids it -- but do consider replacing them :-).
159
160Actually, one good reason is when you already have an existing
161application written in another language that's all done (and done
162well), or you have an application language specifically designed for a
163certain task (e.g. prolog, make).
164
165For various reasons, Perl is probably not well-suited for real-time
166embedded systems, low-level operating systems development work like
167device drivers or context-switching code, complex multithreaded
168shared-memory applications, or extremely large applications. You'll
169notice that perl is not itself written in Perl.
170
171The new native-code compiler for Perl may reduce the limitations given
172in the previous statement to some degree, but understand that Perl
173remains fundamentally a dynamically typed language, and not a
46fc3d4c 174statically typed one. You certainly won't be chastized if you don't
68dc0745 175trust nuclear-plant or brain-surgery monitoring code to it. And
176Larry will sleep easier, too -- Wall Street programs not
177withstanding. :-)
178
179=head2 What's the difference between "perl" and "Perl"?
180
181One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
182signify the language proper and "perl" the implementation of it,
183i.e. the current interpreter. Hence Tom's quip that "Nothing but perl
184can parse Perl." You may or may not choose to follow this usage. For
185example, parallelism means "awk and perl" and "Python and Perl" look
186ok, while "awk and Perl" and "Python and perl" do not.
187
188=head2 Is it a Perl program or a Perl script?
189
190It doesn't matter.
191
192In "standard terminology" a I<program> has been compiled to physical
46fc3d4c 193machine code once, and can then be be run multiple times, whereas a
68dc0745 194I<script> must be translated by a program each time it's used. Perl
195programs, however, are usually neither strictly compiled nor strictly
fc36a67e 196interpreted. They can be compiled to a byte code form (something of a
197Perl virtual machine) or to completely different languages, like C or
198assembly language. You can't tell just by looking whether the source
199is destined for a pure interpreter, a parse-tree interpreter, a byte
200code interpreter, or a native-code compiler, so it's hard to give a
201definitive answer here.
68dc0745 202
203=head2 What is a JAPH?
204
205These are the "just another perl hacker" signatures that some people
206sign their postings with. About 100 of the of the earlier ones are
207available from http://www.perl.com/CPAN/misc/japh .
208
209=head2 Where can I get a list of Larry Wall witticisms?
210
211Over a hundred quips by Larry, from postings of his or source code,
212can be found at http://www.perl.com/CPAN/misc/lwall-quotes .
213
5e3006a4 214=head2 How can I convince my sysadmin/supervisor/employees to use version (5/5.005/Perl instead of some other language)?
68dc0745 215
216If your manager or employees are wary of unsupported software, or
217software which doesn't officially ship with your Operating System, you
218might try to appeal to their self-interest. If programmers can be
219more productive using and utilizing Perl constructs, functionality,
220simplicity, and power, then the typical manager/supervisor/employee
221may be persuaded. Regarding using Perl in general, it's also
222sometimes helpful to point out that delivery times may be reduced
223using Perl, as compared to other languages.
224
225If you have a project which has a bottleneck, especially in terms of
5a964f20 226translation or testing, Perl almost certainly will provide a viable,
68dc0745 227and quick solution. In conjunction with any persuasion effort, you
228should not fail to point out that Perl is used, quite extensively, and
229with extremely reliable and valuable results, at many large computer
230software and/or hardware companies throughout the world. In fact,
231many Unix vendors now ship Perl by default, and support is usually
232just a news-posting away, if you can't find the answer in the
233I<comprehensive> documentation, including this FAQ.
234
235If you face reluctance to upgrading from an older version of perl,
236then point out that version 4 is utterly unmaintained and unsupported
237by the Perl Development Team. Another big sell for Perl5 is the large
238number of modules and extensions which greatly reduce development time
239for any given task. Also mention that the difference between version
2404 and version 5 of Perl is like the difference between awk and C++.
241(Well, ok, maybe not quite that distinct, but you get the idea.) If
242you want support and a reasonable guarantee that what you're
243developing will continue to work in the future, then you have to run
5e3006a4 244the supported version. That probably means running the 5.005 release,
245although 5.004 isn't that bad (it's just one year and one release
68dc0745 246behind). Several important bugs were fixed from the 5.000 through
5e3006a4 2475.003 versions, though, so try upgrading past them if possible.
248
249Of particular note is the massive bughunt for buffer overflow
250problems that went into the 5.004 release. All releases prior to
251that, including perl4, are considered insecure and should be upgraded
252as soon as possible.
68dc0745 253
254=head1 AUTHOR AND COPYRIGHT
255
5a964f20 256Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
257All rights reserved.
258
c8db1d39 259When included as an integrated part of the Standard Distribution
260of Perl or of its documentation (printed or otherwise), this works is
261covered under Perl's Artistic Licence. For separate distributions of
262all or part of this FAQ outside of that, see L<perlfaq>.
263
264Irrespective of its distribution, all code examples here are public
265domain. You are permitted and encouraged to use this code and any
266derivatives thereof in your own programs for fun or for profit as you
267see fit. A simple comment in the code giving credit to the FAQ would
268be courteous but is not required.