Debian Codegraph @

upstream/debian-unstable/man1/perlfaq1.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "PERLFAQ1 1"
58 .TH PERLFAQ1 1 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 perlfaq1 \- General Questions About Perl
65 .SH VERSION
66 .IX Header "VERSION"
67 version 5.20240218
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This section of the FAQ answers very general, high-level questions
71 about Perl.
72 .SS "What is Perl?"
73 .IX Subsection "What is Perl?"
74 Perl is a high-level programming language with an eclectic heritage
75 written by Larry Wall and a cast of thousands.
76 .PP
77 Perl's process, file, and text manipulation facilities make it
78 particularly well-suited for tasks involving quick prototyping, system
79 utilities, software tools, system management tasks, database access,
80 graphical programming, networking, and web programming.
81 .PP
82 Perl derives from the ubiquitous C programming language and to a
83 lesser extent from sed, awk, the Unix shell, and many other tools
84 and languages.
85 .PP
86 These strengths make it especially popular with web developers
87 and system administrators. Mathematicians, geneticists, journalists,
88 managers and many other people also use Perl.
89 .SS "Who supports Perl? Who develops it? Why is it free?"
90 .IX Subsection "Who supports Perl? Who develops it? Why is it free?"
91 The original culture of the pre-populist Internet and the deeply-held
92 beliefs of Perl's author, Larry Wall, gave rise to the free and open
93 distribution policy of Perl. Perl is supported by its users. The
94 core, the standard Perl library, the optional modules, and the
95 documentation you're reading now were all written by volunteers.
96 .PP
97 The core development team (known as the Perl Porters)
98 are a group of highly altruistic individuals committed to
99 producing better software for free than you could hope to purchase for
100 money. You may snoop on pending developments via the
101 archives <http://www.nntp.perl.org/group/perl.perl5.porters/>
102 or you can subscribe to the mailing list by sending
103 perl5\-porters\[email protected] a subscription request
104 (an empty message with no subject is fine).
105 .PP
106 While the GNU project includes Perl in its distributions, there's no
107 such thing as "GNU Perl". Perl is not produced nor maintained by the
108 Free Software Foundation. Perl's licensing terms are also more open
109 than GNU software's tend to be.
110 .PP
111 You can get commercial support of Perl if you wish, although for most
112 users the informal support will more than suffice. See the answer to
113 "Where can I buy a commercial version of Perl?" for more information.
114 .SS "Which version of Perl should I use?"
115 .IX Subsection "Which version of Perl should I use?"
116 (contributed by brian d foy with updates from others)
117 .PP
118 There is often a matter of opinion and taste, and there isn't any one
119 answer that fits everyone. In general, you want to use either the current
120 stable release, or the stable release immediately prior to that one.
121 .PP
122 Beyond that, you have to consider several things and decide which is best
123 for you.
124 .IP \(bu 4
125 If things aren't broken, upgrading perl may break them (or at least issue
126 new warnings).
127 .IP \(bu 4
128 The latest versions of perl have more bug fixes.
129 .IP \(bu 4
130 The latest versions of perl may contain performance improvements and
131 features not present in older versions. There have been many changes
132 in perl since perl5 was first introduced.
133 .IP \(bu 4
134 The Perl community is geared toward supporting the most recent releases,
135 so you'll have an easier time finding help for those.
136 .IP \(bu 4
137 Older versions of perl may have security vulnerabilities, some of which
138 are serious (see perlsec and search
139 CVEs <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=Perl> for more
140 information).
141 .IP \(bu 4
142 The latest versions are probably the least deployed and widely tested, so
143 you may want to wait a few months after their release and see what
144 problems others have if you are risk averse.
145 .IP \(bu 4
146 The immediate, in addition to the current stable release, the previous
147 stable release is maintained. See
148 "MAINTENANCE AND SUPPORT" in perlpolicy for more information.
149 .IP \(bu 4
150 There are really two tracks of perl development: a maintenance version
151 and an experimental version. The maintenance versions are stable, and
152 have an even number as the minor release (i.e. perl5.24.x, where 24 is the
153 minor release). The experimental versions may include features that
154 don't make it into the stable versions, and have an odd number as the
155 minor release (i.e. perl5.25.x, where 25 is the minor release).
156 .IP \(bu 4
157 You can consult releases <http://dev.perl.org/perl5> to determine the
158 current stable release of Perl.
159 .SS "What is Raku (Perl 6)?"
160 .IX Subsection "What is Raku (Perl 6)?"
161 Raku (formerly known as Perl 6) was \fIoriginally\fR described as the community's
162 rewrite of Perl, however as the language evolved, it became clear that it is
163 a separate language, but in the same language family as Perl.
164 .PP
165 Raku is not intended primarily as a replacement for Perl, but as its
166 own thing \- and libraries exist to allow you to call Perl code from Raku
167 programs and vice versa.
168 .PP
169 Contrary to popular belief, Raku and Perl peacefully coexist with one
170 another. Raku has proven to be a fascinating source of ideas for those
171 using Perl (the Moose object system is a well-known example). There is
172 overlap in the communities, and this overlap fosters the tradition of sharing
173 and borrowing that have been instrumental to Perl's success.
174 .PP
175 For more about Raku see <https://www.raku.org/>.
176 .PP
177 "We're really serious about reinventing everything that needs reinventing."
178 \&\-\-Larry Wall
179 .SS "How stable is Perl?"
180 .IX Subsection "How stable is Perl?"
181 Production releases, which incorporate bug fixes and new functionality,
182 are widely tested before release. Since the 5.000 release, we have
183 averaged about one production release per year.
184 .PP
185 The Perl development team occasionally make changes to the
186 internal core of the language, but all possible efforts are made toward
187 backward compatibility.
188 .SS "How often are new versions of Perl released?"
189 .IX Subsection "How often are new versions of Perl released?"
190 Recently, the plan has been to release a new version of Perl roughly every
191 April, but getting the release right is more important than sticking rigidly to
192 a calendar date, so the release date is somewhat flexible. The historical
193 release dates can be viewed at <http://www.cpan.org/src/README.html>.
194 .PP
195 Even numbered minor versions (5.14, 5.16, 5.18) are production versions, and
196 odd numbered minor versions (5.15, 5.17, 5.19) are development versions. Unless
197 you want to try out an experimental feature, you probably never want to install
198 a development version of Perl.
199 .PP
200 The Perl development team are called Perl 5 Porters, and their
201 organization is described at <http://perldoc.perl.org/perlpolicy.html>.
202 The organizational rules really just boil down to one: Larry is always
203 right, even when he was wrong.
204 .SS "Is Perl difficult to learn?"
205 .IX Subsection "Is Perl difficult to learn?"
206 No, Perl is easy to start learning <http://learn.perl.org/> \-\-and easy to keep learning. It looks
207 like most programming languages you're likely to have experience
208 with, so if you've ever written a C program, an awk script, a shell
209 script, or even a BASIC program, you're already partway there.
210 .PP
211 Most tasks only require a small subset of the Perl language. One of
212 the guiding mottos for Perl development is "there's more than one way
213 to do it" (TMTOWTDI, sometimes pronounced "tim toady"). Perl's
214 learning curve is therefore shallow (easy to learn) and long (there's
215 a whole lot you can do if you really want).
216 .PP
217 Finally, because Perl is frequently (but not always, and certainly not by
218 definition) an interpreted language, you can write your programs and test
219 them without an intermediate compilation step, allowing you to experiment
220 and test/debug quickly and easily. This ease of experimentation flattens
221 the learning curve even more.
222 .PP
223 Things that make Perl easier to learn: Unix experience, almost any kind
224 of programming experience, an understanding of regular expressions, and
225 the ability to understand other people's code. If there's something you
226 need to do, then it's probably already been done, and a working example is
227 usually available for free. Don't forget Perl modules, either.
228 They're discussed in Part 3 of this FAQ, along with CPAN <http://www.cpan.org/>, which is
229 discussed in Part 2.
230 .SS "How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?"
231 .IX Subsection "How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?"
232 Perl can be used for almost any coding problem, even ones which require
233 integrating specialist C code for extra speed. As with any tool it can
234 be used well or badly. Perl has many strengths, and a few weaknesses,
235 precisely which areas are good and bad is often a personal choice.
236 .PP
237 When choosing a language you should also be influenced by the
238 resources <http://www.cpan.org/>, testing culture <http://www.cpantesters.org/>
239 and community <http://www.perl.org/community.html> which surrounds it.
240 .PP
241 For comparisons to a specific language it is often best to create
242 a small project in both languages and compare the results, make sure
243 to use all the resources <http://www.cpan.org/> of each language,
244 as a language is far more than just it's syntax.
245 .SS "Can I do [task] in Perl?"
246 .IX Subsection "Can I do [task] in Perl?"
247 Perl is flexible and extensible enough for you to use on virtually any
248 task, from one-line file-processing tasks to large, elaborate systems.
249 .PP
250 For many people, Perl serves as a great replacement for shell scripting.
251 For others, it serves as a convenient, high-level replacement for most of
252 what they'd program in low-level languages like C or C++. It's ultimately
253 up to you (and possibly your management) which tasks you'll use Perl
254 for and which you won't.
255 .PP
256 If you have a library that provides an API, you can make any component
257 of it available as just another Perl function or variable using a Perl
258 extension written in C or C++ and dynamically linked into your main
259 perl interpreter. You can also go the other direction, and write your
260 main program in C or C++, and then link in some Perl code on the fly,
261 to create a powerful application. See perlembed.
262 .PP
263 That said, there will always be small, focused, special-purpose
264 languages dedicated to a specific problem domain that are simply more
265 convenient for certain kinds of problems. Perl tries to be all things
266 to all people, but nothing special to anyone. Examples of specialized
267 languages that come to mind include prolog and matlab.
268 .SS "When shouldn't I program in Perl?"
269 .IX Subsection "When shouldn't I program in Perl?"
270 One good reason is when you already have an existing
271 application written in another language that's all done (and done
272 well), or you have an application language specifically designed for a
273 certain task (e.g. prolog, make).
274 .PP
275 If you find that you need to speed up a specific part of a Perl
276 application (not something you often need) you may want to use C,
277 but you can access this from your Perl code with perlxs.
278 .SS "What's the difference between ""perl"" and ""Perl""?"
279 .IX Subsection "What's the difference between ""perl"" and ""Perl""?"
280 "Perl" is the name of the language. Only the "P" is capitalized.
281 The name of the interpreter (the program which runs the Perl script)
282 is "perl" with a lowercase "p".
283 .PP
284 You may or may not choose to follow this usage. But never write "PERL",
285 because perl is not an acronym.
286 .SS "What is a JAPH?"
287 .IX Subsection "What is a JAPH?"
288 (contributed by brian d foy)
289 .PP
290 JAPH stands for "Just another Perl hacker,", which Randal Schwartz used
291 to sign email and usenet messages starting in the late 1980s. He
292 previously used the phrase with many subjects ("Just another x hacker,"),
293 so to distinguish his JAPH, he started to write them as Perl programs:
294 .PP
295 .Vb 1
296 \& print "Just another Perl hacker,";
297 .Ve
298 .PP
299 Other people picked up on this and started to write clever or obfuscated
300 programs to produce the same output, spinning things quickly out of
301 control while still providing hours of amusement for their creators and
302 readers.
303 .PP
304 CPAN has several JAPH programs at <http://www.cpan.org/misc/japh>.
305 .SS "How can I convince others to use Perl?"
306 .IX Subsection "How can I convince others to use Perl?"
307 (contributed by brian d foy)
308 .PP
309 Appeal to their self interest! If Perl is new (and thus scary) to them,
310 find something that Perl can do to solve one of their problems. That
311 might mean that Perl either saves them something (time, headaches, money)
312 or gives them something (flexibility, power, testability).
313 .PP
314 In general, the benefit of a language is closely related to the skill of
315 the people using that language. If you or your team can be faster,
316 better, and stronger through Perl, you'll deliver more value. Remember,
317 people often respond better to what they get out of it. If you run
318 into resistance, figure out what those people get out of the other
319 choice and how Perl might satisfy that requirement.
320 .PP
321 You don't have to worry about finding or paying for Perl; it's freely
322 available and several popular operating systems come with Perl. Community
323 support in places such as Perlmonks ( <http://www.perlmonks.com> )
324 and the various Perl mailing lists ( <http://lists.perl.org> ) means that
325 you can usually get quick answers to your problems.
326 .PP
327 Finally, keep in mind that Perl might not be the right tool for every
328 job. You're a much better advocate if your claims are reasonable and
329 grounded in reality. Dogmatically advocating anything tends to make
330 people discount your message. Be honest about possible disadvantages
331 to your choice of Perl since any choice has trade-offs.
332 .PP
333 You might find these links useful:
334 .IP \(bu 4
335 <http://www.perl.org/about.html>
336 .IP \(bu 4
337 <http://perltraining.com.au/whyperl.html>
338 .SH "AUTHOR AND COPYRIGHT"
339 .IX Header "AUTHOR AND COPYRIGHT"
340 Copyright (c) 1997\-2010 Tom Christiansen, Nathan Torkington, and
341 other authors as noted. All rights reserved.
342 .PP
343 This documentation is free; you can redistribute it and/or modify it
344 under the same terms as Perl itself.
345 .PP
346 Irrespective of its distribution, all code examples here are in the public
347 domain. You are permitted and encouraged to use this code and any
348 derivatives thereof in your own programs for fun or for profit as you
349 see fit. A simple comment in the code giving credit to the FAQ would
350 be courteous but is not required.