Debian Codegraph @

upstream/mageia-cauldron/man1/perlfaq1.1

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