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