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