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