This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update perlfaq to CPAN version 5.0150043
[perl5.git] / cpan / perlfaq / lib / perlfaq1.pod
1 =head1 NAME
2
3 perlfaq1 - General Questions About Perl
4
5 =head1 DESCRIPTION
6
7 This section of the FAQ answers very general, high-level questions
8 about Perl.
9
10 =head2 What is Perl?
11
12 Perl is a high-level programming language with an eclectic heritage
13 written by Larry Wall and a cast of thousands.
14
15 Perl's process, file, and text manipulation facilities make it
16 particularly well-suited for tasks involving quick prototyping, system
17 utilities, software tools, system management tasks, database access,
18 graphical programming, networking, and web programming.
19
20 Perl derives from the ubiquitous C programming language and to a
21 lesser extent from sed, awk, the Unix shell, and many other tools
22 and languages.
23
24 These strengths make it especially popular with web developers
25 and system administrators. Mathematicians, geneticists, journalists,
26 managers and many other people also use Perl.
27
28 =head2 Who supports Perl? Who develops it? Why is it free?
29
30 The original culture of the pre-populist Internet and the deeply-held
31 beliefs of Perl's author, Larry Wall, gave rise to the free and open
32 distribution policy of Perl. Perl is supported by its users. The
33 core, the standard Perl library, the optional modules, and the
34 documentation you're reading now were all written by volunteers.
35
36 The core development team (known as the Perl Porters)
37 are a group of highly altruistic individuals committed to
38 producing better software for free than you could hope to purchase for
39 money. You may snoop on pending developments via the
40 L<archives|http://www.nntp.perl.org/group/perl.perl5.porters/>
41 or read the L<faq|http://dev.perl.org/perl5/docs/p5p-faq.html>,
42 or you can subscribe to the mailing list by sending
43 perl5-porters-subscribe@perl.org a subscription request
44 (an empty message with no subject is fine).
45
46 While the GNU project includes Perl in its distributions, there's no
47 such thing as "GNU Perl". Perl is not produced nor maintained by the
48 Free Software Foundation. Perl's licensing terms are also more open
49 than GNU software's tend to be.
50
51 You can get commercial support of Perl if you wish, although for most
52 users the informal support will more than suffice. See the answer to
53 "Where can I buy a commercial version of Perl?" for more information.
54
55 =head2 Which version of Perl should I use?
56
57 (contributed by brian d foy)
58
59 There is often a matter of opinion and taste, and there isn't any one
60 answer that fits everyone. In general, you want to use either the current
61 stable release, or the stable release immediately prior to that one.
62 Currently, those are perl5.14.x and perl5.12.x, respectively.
63
64 Beyond that, you have to consider several things and decide which is best
65 for you.
66
67 =over 4
68
69 =item *
70
71 If things aren't broken, upgrading perl may break them (or at least issue
72 new warnings).
73
74 =item *
75
76 The latest versions of perl have more bug fixes.
77
78 =item *
79
80 The Perl community is geared toward supporting the most recent releases,
81 so you'll have an easier time finding help for those.
82
83 =item *
84
85 Versions prior to perl5.004 had serious security problems with buffer
86 overflows, and in some cases have CERT advisories (for instance,
87 L<http://www.cert.org/advisories/CA-1997-17.html> ).
88
89 =item *
90
91 The latest versions are probably the least deployed and widely tested, so
92 you may want to wait a few months after their release and see what
93 problems others have if you are risk averse.
94
95 =item *
96
97 The immediate, previous releases (i.e. perl5.8.x ) are usually maintained
98 for a while, although not at the same level as the current releases.
99
100 =item *
101
102 No one is actively supporting Perl 4. Ten years ago it was a dead
103 camel carcass (according to this document). Now it's barely a skeleton
104 as its whitewashed bones have fractured or eroded.
105
106 =item *
107
108 The current leading implementation of Perl 6, Rakudo, released a "useful,
109 usable, 'early adopter'" distribution of Perl 6 (called Rakudo Star) in July of
110 2010. Please see L<http://rakudo.org/> for more information.
111
112 =item *
113
114 There are really two tracks of perl development: a maintenance version
115 and an experimental version. The maintenance versions are stable, and
116 have an even number as the minor release (i.e. perl5.10.x, where 10 is the
117 minor release). The experimental versions may include features that
118 don't make it into the stable versions, and have an odd number as the
119 minor release (i.e. perl5.9.x, where 9 is the minor release).
120
121 =back
122
123 =head2 What are Perl 4, Perl 5, or Perl 6?
124
125 In short, Perl 4 is the parent to both Perl 5 and Perl 6. Perl 5 is the older
126 sibling, and though they are different languages, someone who knows one will
127 spot many similarities in the other.
128
129 The number after Perl (i.e. the 5 after Perl 5) is the major release
130 of the perl interpreter as well as the version of the language. Each
131 major version has significant differences that earlier versions cannot
132 support.
133
134 The current major release of Perl is Perl 5, first released in
135 1994. It can run scripts from the previous major release, Perl 4
136 (March 1991), but has significant differences.
137
138 Perl 6 is a reinvention of Perl, it is a language in the same lineage but
139 not compatible. The two are complementary, not mutually exclusive. Perl 6 is
140 not meant to replace Perl 5, and vice versa. See L</"What is Perl 6?"> below
141 to find out more.
142
143 See L<perlhist> for a history of Perl revisions.
144
145 =head2 What is Perl 6?
146
147 Perl 6 was I<originally> described as the community's rewrite of Perl 5.
148 Development started in 2002; syntax and design work continue to this day.
149 As the language has evolved, it has become clear that it is a separate
150 language, incompatible with Perl 5 but in the same language family.
151
152 Contrary to popular belief, Perl 6 and Perl 5 peacefully coexist with one
153 another. Perl 6 has proven to be a fascinating source of ideas for those
154 using Perl 5 (the L<Moose> object system is a well-known example). There is
155 overlap in the communities, and this overlap fosters the tradition of sharing
156 and borrowing that have been instrumental to Perl's success. The current
157 leading implementation of Perl 6 is Rakudo, and you can learn more about
158 it at L<http://rakudo.org>.
159
160 If you want to learn more about Perl 6, or have a desire to help in
161 the crusade to make Perl a better place then read the Perl 6 developers
162 page at L<http://www.perl6.org/> and get involved.
163
164 "We're really serious about reinventing everything that needs reinventing."
165 --Larry Wall
166
167 =head2 How stable is Perl?
168
169 Production releases, which incorporate bug fixes and new functionality,
170 are widely tested before release. Since the 5.000 release, we have
171 averaged about one production release per year.
172
173 The Perl development team occasionally make changes to the
174 internal core of the language, but all possible efforts are made toward
175 backward compatibility.
176
177 =head2 Is Perl difficult to learn?
178
179 No, Perl is easy to start L<learning|http://learn.perl.org/> --and easy to keep learning. It looks
180 like most programming languages you're likely to have experience
181 with, so if you've ever written a C program, an awk script, a shell
182 script, or even a BASIC program, you're already partway there.
183
184 Most tasks only require a small subset of the Perl language. One of
185 the guiding mottos for Perl development is "there's more than one way
186 to do it" (TMTOWTDI, sometimes pronounced "tim toady"). Perl's
187 learning curve is therefore shallow (easy to learn) and long (there's
188 a whole lot you can do if you really want).
189
190 Finally, because Perl is frequently (but not always, and certainly not by
191 definition) an interpreted language, you can write your programs and test
192 them without an intermediate compilation step, allowing you to experiment
193 and test/debug quickly and easily. This ease of experimentation flattens
194 the learning curve even more.
195
196 Things that make Perl easier to learn: Unix experience, almost any kind
197 of programming experience, an understanding of regular expressions, and
198 the ability to understand other people's code. If there's something you
199 need to do, then it's probably already been done, and a working example is
200 usually available for free. Don't forget Perl modules, either.
201 They're discussed in Part 3 of this FAQ, along with L<CPAN|http://www.cpan.org/>, which is
202 discussed in Part 2.
203
204 =head2 How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
205
206 Perl can be used for almost any coding problem, even ones which require
207 integrating specialist C code for extra speed. As with any tool it can
208 be used well or badly. Perl has many strengths, and a few weaknesses,
209 precisely which areas are good and bad is often a personal choice.
210
211 When choosing a language you should also be influenced by the
212 L<resources|http://www.cpan.org/>, L<testing culture|http://www.cpantesters.org/>
213 and L<community|http://www.perl.org/community.html> which surrounds it.
214
215 For comparisons to a specific language it is often best to create
216 a small project in both languages and compare the results, make sure
217 to use all the L<resources|http://www.cpan.org/> of each language,
218 as a language is far more than just it's syntax.
219
220 =head2 Can I do [task] in Perl?
221
222 Perl is flexible and extensible enough for you to use on virtually any
223 task, from one-line file-processing tasks to large, elaborate systems.
224
225 For many people, Perl serves as a great replacement for shell scripting.
226 For others, it serves as a convenient, high-level replacement for most of
227 what they'd program in low-level languages like C or C++. It's ultimately
228 up to you (and possibly your management) which tasks you'll use Perl
229 for and which you won't.
230
231 If you have a library that provides an API, you can make any component
232 of it available as just another Perl function or variable using a Perl
233 extension written in C or C++ and dynamically linked into your main
234 perl interpreter. You can also go the other direction, and write your
235 main program in C or C++, and then link in some Perl code on the fly,
236 to create a powerful application. See L<perlembed>.
237
238 That said, there will always be small, focused, special-purpose
239 languages dedicated to a specific problem domain that are simply more
240 convenient for certain kinds of problems. Perl tries to be all things
241 to all people, but nothing special to anyone. Examples of specialized
242 languages that come to mind include prolog and matlab.
243
244 =head2 When shouldn't I program in Perl?
245
246 One good reason is when you already have an existing
247 application written in another language that's all done (and done
248 well), or you have an application language specifically designed for a
249 certain task (e.g. prolog, make).
250
251 If you find that you need to speed up a specific part of a Perl
252 application (not something you often need) you may want to use C,
253 but you can access this from your Perl code with L<perlxs>.
254
255 =head2 What's the difference between "perl" and "Perl"?
256
257 "Perl" is the name of the language. Only the "P" is capitalized.
258 The name of the interpreter (the program which runs the Perl script)
259 is "perl" with a lowercase "p".
260
261 You may or may not choose to follow this usage. But never write "PERL",
262 because perl is not an acronym.
263
264 =head2 What is a JAPH?
265
266 (contributed by brian d foy)
267
268 JAPH stands for "Just another Perl hacker,", which Randal Schwartz used
269 to sign email and usenet messages starting in the late 1980s. He
270 previously used the phrase with many subjects ("Just another x hacker,"),
271 so to distinguish his JAPH, he started to write them as Perl programs:
272
273     print "Just another Perl hacker,";
274
275 Other people picked up on this and started to write clever or obfuscated
276 programs to produce the same output, spinning things quickly out of
277 control while still providing hours of amusement for their creators and
278 readers.
279
280 CPAN has several JAPH programs at L<http://www.cpan.org/misc/japh>.
281
282 =head2 How can I convince others to use Perl?
283
284 (contributed by brian d foy)
285
286 Appeal to their self interest! If Perl is new (and thus scary) to them,
287 find something that Perl can do to solve one of their problems. That
288 might mean that Perl either saves them something (time, headaches, money)
289 or gives them something (flexibility, power, testability).
290
291 In general, the benefit of a language is closely related to the skill of
292 the people using that language. If you or your team can be faster,
293 better, and stronger through Perl, you'll deliver more value. Remember,
294 people often respond better to what they get out of it. If you run
295 into resistance, figure out what those people get out of the other
296 choice and how Perl might satisfy that requirement.
297
298 You don't have to worry about finding or paying for Perl; it's freely
299 available and several popular operating systems come with Perl. Community
300 support in places such as Perlmonks ( L<http://www.perlmonks.com> )
301 and the various Perl mailing lists ( L<http://lists.perl.org> ) means that
302 you can usually get quick answers to your problems.
303
304 Finally, keep in mind that Perl might not be the right tool for every
305 job. You're a much better advocate if your claims are reasonable and
306 grounded in reality. Dogmatically advocating anything tends to make
307 people discount your message. Be honest about possible disadvantages
308 to your choice of Perl since any choice has trade-offs.
309
310 You might find these links useful:
311
312 =over 4
313
314 =item * L<http://www.perl.org/about.html>
315
316 =item * L<http://perltraining.com.au/whyperl.html>
317
318 =back
319
320 =head1 AUTHOR AND COPYRIGHT
321
322 Copyright (c) 1997-2010 Tom Christiansen, Nathan Torkington, and
323 other authors as noted. All rights reserved.
324
325 This documentation is free; you can redistribute it and/or modify it
326 under the same terms as Perl itself.
327
328 Irrespective of its distribution, all code examples here are in the public
329 domain. You are permitted and encouraged to use this code and any
330 derivatives thereof in your own programs for fun or for profit as you
331 see fit. A simple comment in the code giving credit to the FAQ would
332 be courteous but is not required.