1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
|
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "PERLFAQ 1perl"
.TH PERLFAQ 1perl 2024-02-11 "perl v5.38.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
perlfaq \- Frequently asked questions about Perl
.SH VERSION
.IX Header "VERSION"
version 5.20210520
.SH DESCRIPTION
.IX Header "DESCRIPTION"
The perlfaq comprises several documents that answer the most commonly
asked questions about Perl and Perl programming. It's divided by topic
into nine major sections outlined in this document.
.SS "Where to find the perlfaq"
.IX Subsection "Where to find the perlfaq"
The perlfaq is an evolving document. Read the latest version at
<https://perldoc.perl.org/perlfaq>. It is also included in the standard Perl
distribution.
.SS "How to use the perlfaq"
.IX Subsection "How to use the perlfaq"
The \f(CW\*(C`perldoc\*(C'\fR command line tool is part of the standard Perl distribution. To
read the perlfaq:
.PP
.Vb 1
\& $ perldoc perlfaq
.Ve
.PP
To search the perlfaq question headings:
.PP
.Vb 1
\& $ perldoc \-q open
.Ve
.SS "How to contribute to the perlfaq"
.IX Subsection "How to contribute to the perlfaq"
Review <https://github.com/perl\-doc\-cats/perlfaq/wiki>. If you don't find
your suggestion create an issue or pull request against
<https://github.com/perl\-doc\-cats/perlfaq>.
.PP
Once approved, changes will be distributed with the next Perl release and
subsequently appear at <https://perldoc.perl.org/perlfaq>.
.SS "What if my question isn't answered in the FAQ?"
.IX Subsection "What if my question isn't answered in the FAQ?"
Try the resources in perlfaq2.
.SH "TABLE OF CONTENTS"
.IX Header "TABLE OF CONTENTS"
.IP "perlfaq1 \- General Questions About Perl" 4
.IX Item "perlfaq1 - General Questions About Perl"
.PD 0
.IP "perlfaq2 \- Obtaining and Learning about Perl" 4
.IX Item "perlfaq2 - Obtaining and Learning about Perl"
.IP "perlfaq3 \- Programming Tools" 4
.IX Item "perlfaq3 - Programming Tools"
.IP "perlfaq4 \- Data Manipulation" 4
.IX Item "perlfaq4 - Data Manipulation"
.IP "perlfaq5 \- Files and Formats" 4
.IX Item "perlfaq5 - Files and Formats"
.IP "perlfaq6 \- Regular Expressions" 4
.IX Item "perlfaq6 - Regular Expressions"
.IP "perlfaq7 \- General Perl Language Issues" 4
.IX Item "perlfaq7 - General Perl Language Issues"
.IP "perlfaq8 \- System Interaction" 4
.IX Item "perlfaq8 - System Interaction"
.IP "perlfaq9 \- Web, Email and Networking" 4
.IX Item "perlfaq9 - Web, Email and Networking"
.PD
.SH "THE QUESTIONS"
.IX Header "THE QUESTIONS"
.SS "perlfaq1: General Questions About Perl"
.IX Subsection "perlfaq1: General Questions About Perl"
This section of the FAQ answers very general, high-level questions about Perl.
.IP \(bu 4
What is Perl?
.IP \(bu 4
Who supports Perl? Who develops it? Why is it free?
.IP \(bu 4
Which version of Perl should I use?
.IP \(bu 4
What are Perl 4, Perl 5, or Raku (Perl 6)?
.IP \(bu 4
What is Raku (Perl 6)?
.IP \(bu 4
How stable is Perl?
.IP \(bu 4
How often are new versions of Perl released?
.IP \(bu 4
Is Perl difficult to learn?
.IP \(bu 4
How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
.IP \(bu 4
Can I do [task] in Perl?
.IP \(bu 4
When shouldn't I program in Perl?
.IP \(bu 4
What's the difference between "perl" and "Perl"?
.IP \(bu 4
What is a JAPH?
.IP \(bu 4
How can I convince others to use Perl?
.SS "perlfaq2: Obtaining and Learning about Perl"
.IX Subsection "perlfaq2: Obtaining and Learning about Perl"
This section of the FAQ answers questions about where to find source and documentation for Perl, support, and related matters.
.IP \(bu 4
What machines support Perl? Where do I get it?
.IP \(bu 4
How can I get a binary version of Perl?
.IP \(bu 4
I don't have a C compiler. How can I build my own Perl interpreter?
.IP \(bu 4
I copied the Perl binary from one machine to another, but scripts don't work.
.IP \(bu 4
I grabbed the sources and tried to compile but gdbm/dynamic loading/malloc/linking/... failed. How do I make it work?
.IP \(bu 4
What modules and extensions are available for Perl? What is CPAN?
.IP \(bu 4
Where can I get information on Perl?
.IP \(bu 4
What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org?
.IP \(bu 4
Where can I post questions?
.IP \(bu 4
Perl Books
.IP \(bu 4
Which magazines have Perl content?
.IP \(bu 4
Which Perl blogs should I read?
.IP \(bu 4
What mailing lists are there for Perl?
.IP \(bu 4
Where can I buy a commercial version of Perl?
.IP \(bu 4
Where do I send bug reports?
.SS "perlfaq3: Programming Tools"
.IX Subsection "perlfaq3: Programming Tools"
This section of the FAQ answers questions related to programmer tools and programming support.
.IP \(bu 4
How do I do (anything)?
.IP \(bu 4
How can I use Perl interactively?
.IP \(bu 4
How do I find which modules are installed on my system?
.IP \(bu 4
How do I debug my Perl programs?
.IP \(bu 4
How do I profile my Perl programs?
.IP \(bu 4
How do I cross-reference my Perl programs?
.IP \(bu 4
Is there a pretty-printer (formatter) for Perl?
.IP \(bu 4
Is there an IDE or Windows Perl Editor?
.IP \(bu 4
Where can I get Perl macros for vi?
.IP \(bu 4
Where can I get perl-mode or cperl-mode for emacs?
.IP \(bu 4
How can I use curses with Perl?
.IP \(bu 4
How can I write a GUI (X, Tk, Gtk, etc.) in Perl?
.IP \(bu 4
How can I make my Perl program run faster?
.IP \(bu 4
How can I make my Perl program take less memory?
.IP \(bu 4
Is it safe to return a reference to local or lexical data?
.IP \(bu 4
How can I free an array or hash so my program shrinks?
.IP \(bu 4
How can I make my CGI script more efficient?
.IP \(bu 4
How can I hide the source for my Perl program?
.IP \(bu 4
How can I compile my Perl program into byte code or C?
.IP \(bu 4
How can I get \f(CW\*(C`#!perl\*(C'\fR to work on [MS\-DOS,NT,...]?
.IP \(bu 4
Can I write useful Perl programs on the command line?
.IP \(bu 4
Why don't Perl one-liners work on my DOS/Mac/VMS system?
.IP \(bu 4
Where can I learn about CGI or Web programming in Perl?
.IP \(bu 4
Where can I learn about object-oriented Perl programming?
.IP \(bu 4
Where can I learn about linking C with Perl?
.IP \(bu 4
I've read perlembed, perlguts, etc., but I can't embed perl in my C program; what am I doing wrong?
.IP \(bu 4
When I tried to run my script, I got this message. What does it mean?
.IP \(bu 4
What's MakeMaker?
.SS "perlfaq4: Data Manipulation"
.IX Subsection "perlfaq4: Data Manipulation"
This section of the FAQ answers questions related to manipulating numbers, dates, strings, arrays, hashes, and miscellaneous data issues.
.IP \(bu 4
Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?
.IP \(bu 4
Why is \fBint()\fR broken?
.IP \(bu 4
Why isn't my octal data interpreted correctly?
.IP \(bu 4
Does Perl have a \fBround()\fR function? What about \fBceil()\fR and \fBfloor()\fR? Trig functions?
.IP \(bu 4
How do I convert between numeric representations/bases/radixes?
.IP \(bu 4
Why doesn't & work the way I want it to?
.IP \(bu 4
How do I multiply matrices?
.IP \(bu 4
How do I perform an operation on a series of integers?
.IP \(bu 4
How can I output Roman numerals?
.IP \(bu 4
Why aren't my random numbers random?
.IP \(bu 4
How do I get a random number between X and Y?
.IP \(bu 4
How do I find the day or week of the year?
.IP \(bu 4
How do I find the current century or millennium?
.IP \(bu 4
How can I compare two dates and find the difference?
.IP \(bu 4
How can I take a string and turn it into epoch seconds?
.IP \(bu 4
How can I find the Julian Day?
.IP \(bu 4
How do I find yesterday's date?
.IP \(bu 4
Does Perl have a Year 2000 or 2038 problem? Is Perl Y2K compliant?
.IP \(bu 4
How do I validate input?
.IP \(bu 4
How do I unescape a string?
.IP \(bu 4
How do I remove consecutive pairs of characters?
.IP \(bu 4
How do I expand function calls in a string?
.IP \(bu 4
How do I find matching/nesting anything?
.IP \(bu 4
How do I reverse a string?
.IP \(bu 4
How do I expand tabs in a string?
.IP \(bu 4
How do I reformat a paragraph?
.IP \(bu 4
How can I access or change N characters of a string?
.IP \(bu 4
How do I change the Nth occurrence of something?
.IP \(bu 4
How can I count the number of occurrences of a substring within a string?
.IP \(bu 4
How do I capitalize all the words on one line?
.IP \(bu 4
How can I split a [character]\-delimited string except when inside [character]?
.IP \(bu 4
How do I strip blank space from the beginning/end of a string?
.IP \(bu 4
How do I pad a string with blanks or pad a number with zeroes?
.IP \(bu 4
How do I extract selected columns from a string?
.IP \(bu 4
How do I find the soundex value of a string?
.IP \(bu 4
How can I expand variables in text strings?
.IP \(bu 4
Does Perl have anything like Ruby's #{} or Python's f string?
.IP \(bu 4
What's wrong with always quoting "$vars"?
.IP \(bu 4
Why don't my <<HERE documents work?
.IP \(bu 4
What is the difference between a list and an array?
.IP \(bu 4
What is the difference between \f(CW$array\fR[1] and \f(CW@array\fR[1]?
.IP \(bu 4
How can I remove duplicate elements from a list or array?
.IP \(bu 4
How can I tell whether a certain element is contained in a list or array?
.IP \(bu 4
How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
.IP \(bu 4
How do I test whether two arrays or hashes are equal?
.IP \(bu 4
How do I find the first array element for which a condition is true?
.IP \(bu 4
How do I handle linked lists?
.IP \(bu 4
How do I handle circular lists?
.IP \(bu 4
How do I shuffle an array randomly?
.IP \(bu 4
How do I process/modify each element of an array?
.IP \(bu 4
How do I select a random element from an array?
.IP \(bu 4
How do I permute N elements of a list?
.IP \(bu 4
How do I sort an array by (anything)?
.IP \(bu 4
How do I manipulate arrays of bits?
.IP \(bu 4
Why does \fBdefined()\fR return true on empty arrays and hashes?
.IP \(bu 4
How do I process an entire hash?
.IP \(bu 4
How do I merge two hashes?
.IP \(bu 4
What happens if I add or remove keys from a hash while iterating over it?
.IP \(bu 4
How do I look up a hash element by value?
.IP \(bu 4
How can I know how many entries are in a hash?
.IP \(bu 4
How do I sort a hash (optionally by value instead of key)?
.IP \(bu 4
How can I always keep my hash sorted?
.IP \(bu 4
What's the difference between "delete" and "undef" with hashes?
.IP \(bu 4
Why don't my tied hashes make the defined/exists distinction?
.IP \(bu 4
How do I reset an \fBeach()\fR operation part-way through?
.IP \(bu 4
How can I get the unique keys from two hashes?
.IP \(bu 4
How can I store a multidimensional array in a DBM file?
.IP \(bu 4
How can I make my hash remember the order I put elements into it?
.IP \(bu 4
Why does passing a subroutine an undefined element in a hash create it?
.IP \(bu 4
How can I make the Perl equivalent of a C structure/C++ class/hash or array of hashes or arrays?
.IP \(bu 4
How can I use a reference as a hash key?
.IP \(bu 4
How can I check if a key exists in a multilevel hash?
.IP \(bu 4
How can I prevent addition of unwanted keys into a hash?
.IP \(bu 4
How do I handle binary data correctly?
.IP \(bu 4
How do I determine whether a scalar is a number/whole/integer/float?
.IP \(bu 4
How do I keep persistent data across program calls?
.IP \(bu 4
How do I print out or copy a recursive data structure?
.IP \(bu 4
How do I define methods for every class/object?
.IP \(bu 4
How do I verify a credit card checksum?
.IP \(bu 4
How do I pack arrays of doubles or floats for XS code?
.SS "perlfaq5: Files and Formats"
.IX Subsection "perlfaq5: Files and Formats"
This section deals with I/O and the "f" issues: filehandles, flushing, formats, and footers.
.IP \(bu 4
How do I flush/unbuffer an output filehandle? Why must I do this?
.IP \(bu 4
How do I change, delete, or insert a line in a file, or append to the beginning of a file?
.IP \(bu 4
How do I count the number of lines in a file?
.IP \(bu 4
How do I delete the last N lines from a file?
.IP \(bu 4
How can I use Perl's \f(CW\*(C`\-i\*(C'\fR option from within a program?
.IP \(bu 4
How can I copy a file?
.IP \(bu 4
How do I make a temporary file name?
.IP \(bu 4
How can I manipulate fixed-record-length files?
.IP \(bu 4
How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles?
.IP \(bu 4
How can I use a filehandle indirectly?
.IP \(bu 4
How can I open a filehandle to a string?
.IP \(bu 4
How can I set up a footer format to be used with \fBwrite()\fR?
.IP \(bu 4
How can I \fBwrite()\fR into a string?
.IP \(bu 4
How can I output my numbers with commas added?
.IP \(bu 4
How can I translate tildes (~) in a filename?
.IP \(bu 4
How come when I open a file read-write it wipes it out?
.IP \(bu 4
Why do I sometimes get an "Argument list too long" when I use <*>?
.IP \(bu 4
How can I open a file named with a leading ">" or trailing blanks?
.IP \(bu 4
How can I reliably rename a file?
.IP \(bu 4
How can I lock a file?
.IP \(bu 4
Why can't I just open(FH, ">file.lock")?
.IP \(bu 4
I still don't get locking. I just want to increment the number in the file. How can I do this?
.IP \(bu 4
All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?
.IP \(bu 4
How do I randomly update a binary file?
.IP \(bu 4
How do I get a file's timestamp in perl?
.IP \(bu 4
How do I set a file's timestamp in perl?
.IP \(bu 4
How do I print to more than one file at once?
.IP \(bu 4
How can I read in an entire file all at once?
.IP \(bu 4
How can I read in a file by paragraphs?
.IP \(bu 4
How can I read a single character from a file? From the keyboard?
.IP \(bu 4
How can I tell whether there's a character waiting on a filehandle?
.IP \(bu 4
How do I do a \f(CW\*(C`tail \-f\*(C'\fR in perl?
.IP \(bu 4
How do I \fBdup()\fR a filehandle in Perl?
.IP \(bu 4
How do I close a file descriptor by number?
.IP \(bu 4
Why can't I use "C:\etemp\efoo" in DOS paths? Why doesn't `C:\etemp\efoo.exe` work?
.IP \(bu 4
Why doesn't glob("*.*") get all the files?
.IP \(bu 4
Why does Perl let me delete read-only files? Why does \f(CW\*(C`\-i\*(C'\fR clobber protected files? Isn't this a bug in Perl?
.IP \(bu 4
How do I select a random line from a file?
.IP \(bu 4
Why do I get weird spaces when I print an array of lines?
.IP \(bu 4
How do I traverse a directory tree?
.IP \(bu 4
How do I delete a directory tree?
.IP \(bu 4
How do I copy an entire directory?
.SS "perlfaq6: Regular Expressions"
.IX Subsection "perlfaq6: Regular Expressions"
This section is surprisingly small because the rest of the FAQ is littered with answers involving regular expressions. For example, decoding a URL and checking whether something is a number can be handled with regular expressions, but those answers are found elsewhere in this document (in perlfaq9 : "How do I decode or create those %\-encodings on the web" and perlfaq4 : "How do I determine whether a scalar is a number/whole/integer/float", to be precise).
.IP \(bu 4
How can I hope to use regular expressions without creating illegible and unmaintainable code?
.IP \(bu 4
I'm having trouble matching over more than one line. What's wrong?
.IP \(bu 4
How can I pull out lines between two patterns that are themselves on different lines?
.IP \(bu 4
How do I match XML, HTML, or other nasty, ugly things with a regex?
.IP \(bu 4
I put a regular expression into $/ but it didn't work. What's wrong?
.IP \(bu 4
How do I substitute case-insensitively on the LHS while preserving case on the RHS?
.IP \(bu 4
How can I make \f(CW\*(C`\ew\*(C'\fR match national character sets?
.IP \(bu 4
How can I match a locale-smart version of \f(CW\*(C`/[a\-zA\-Z]/\*(C'\fR ?
.IP \(bu 4
How can I quote a variable to use in a regex?
.IP \(bu 4
What is \f(CW\*(C`/o\*(C'\fR really for?
.IP \(bu 4
How do I use a regular expression to strip C\-style comments from a file?
.IP \(bu 4
Can I use Perl regular expressions to match balanced text?
.IP \(bu 4
What does it mean that regexes are greedy? How can I get around it?
.IP \(bu 4
How do I process each word on each line?
.IP \(bu 4
How can I print out a word-frequency or line-frequency summary?
.IP \(bu 4
How can I do approximate matching?
.IP \(bu 4
How do I efficiently match many regular expressions at once?
.IP \(bu 4
Why don't word-boundary searches with \f(CW\*(C`\eb\*(C'\fR work for me?
.IP \(bu 4
Why does using $&, $`, or $' slow my program down?
.IP \(bu 4
What good is \f(CW\*(C`\eG\*(C'\fR in a regular expression?
.IP \(bu 4
Are Perl regexes DFAs or NFAs? Are they POSIX compliant?
.IP \(bu 4
What's wrong with using grep in a void context?
.IP \(bu 4
How can I match strings with multibyte characters?
.IP \(bu 4
How do I match a regular expression that's in a variable?
.SS "perlfaq7: General Perl Language Issues"
.IX Subsection "perlfaq7: General Perl Language Issues"
This section deals with general Perl language issues that don't clearly fit into any of the other sections.
.IP \(bu 4
Can I get a BNF/yacc/RE for the Perl language?
.IP \(bu 4
What are all these $@%&* punctuation signs, and how do I know when to use them?
.IP \(bu 4
Do I always/never have to quote my strings or use semicolons and commas?
.IP \(bu 4
How do I skip some return values?
.IP \(bu 4
How do I temporarily block warnings?
.IP \(bu 4
What's an extension?
.IP \(bu 4
Why do Perl operators have different precedence than C operators?
.IP \(bu 4
How do I declare/create a structure?
.IP \(bu 4
How do I create a module?
.IP \(bu 4
How do I adopt or take over a module already on CPAN?
.IP \(bu 4
How do I create a class?
.IP \(bu 4
How can I tell if a variable is tainted?
.IP \(bu 4
What's a closure?
.IP \(bu 4
What is variable suicide and how can I prevent it?
.IP \(bu 4
How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?
.IP \(bu 4
How do I create a static variable?
.IP \(bu 4
What's the difference between dynamic and lexical (static) scoping? Between \fBlocal()\fR and \fBmy()\fR?
.IP \(bu 4
How can I access a dynamic variable while a similarly named lexical is in scope?
.IP \(bu 4
What's the difference between deep and shallow binding?
.IP \(bu 4
Why doesn't "my($foo) = <$fh>;" work right?
.IP \(bu 4
How do I redefine a builtin function, operator, or method?
.IP \(bu 4
What's the difference between calling a function as &foo and \fBfoo()\fR?
.IP \(bu 4
How do I create a switch or case statement?
.IP \(bu 4
How can I catch accesses to undefined variables, functions, or methods?
.IP \(bu 4
Why can't a method included in this same file be found?
.IP \(bu 4
How can I find out my current or calling package?
.IP \(bu 4
How can I comment out a large block of Perl code?
.IP \(bu 4
How do I clear a package?
.IP \(bu 4
How can I use a variable as a variable name?
.IP \(bu 4
What does "bad interpreter" mean?
.IP \(bu 4
Do I need to recompile XS modules when there is a change in the C library?
.SS "perlfaq8: System Interaction"
.IX Subsection "perlfaq8: System Interaction"
This section of the Perl FAQ covers questions involving operating system interaction. Topics include interprocess communication (IPC), control over the user-interface (keyboard, screen and pointing devices), and most anything else not related to data manipulation.
.IP \(bu 4
How do I find out which operating system I'm running under?
.IP \(bu 4
How come \fBexec()\fR doesn't return?
.IP \(bu 4
How do I do fancy stuff with the keyboard/screen/mouse?
.IP \(bu 4
How do I print something out in color?
.IP \(bu 4
How do I read just one key without waiting for a return key?
.IP \(bu 4
How do I check whether input is ready on the keyboard?
.IP \(bu 4
How do I clear the screen?
.IP \(bu 4
How do I get the screen size?
.IP \(bu 4
How do I ask the user for a password?
.IP \(bu 4
How do I read and write the serial port?
.IP \(bu 4
How do I decode encrypted password files?
.IP \(bu 4
How do I start a process in the background?
.IP \(bu 4
How do I trap control characters/signals?
.IP \(bu 4
How do I modify the shadow password file on a Unix system?
.IP \(bu 4
How do I set the time and date?
.IP \(bu 4
How can I \fBsleep()\fR or \fBalarm()\fR for under a second?
.IP \(bu 4
How can I measure time under a second?
.IP \(bu 4
How can I do an \fBatexit()\fR or \fBsetjmp()\fR/\fBlongjmp()\fR? (Exception handling)
.IP \(bu 4
Why doesn't my sockets program work under System V (Solaris)? What does the error message "Protocol not supported" mean?
.IP \(bu 4
How can I call my system's unique C functions from Perl?
.IP \(bu 4
Where do I get the include files to do \fBioctl()\fR or \fBsyscall()\fR?
.IP \(bu 4
Why do setuid perl scripts complain about kernel problems?
.IP \(bu 4
How can I open a pipe both to and from a command?
.IP \(bu 4
Why can't I get the output of a command with \fBsystem()\fR?
.IP \(bu 4
How can I capture STDERR from an external command?
.IP \(bu 4
Why doesn't \fBopen()\fR return an error when a pipe open fails?
.IP \(bu 4
What's wrong with using backticks in a void context?
.IP \(bu 4
How can I call backticks without shell processing?
.IP \(bu 4
Why can't my script read from STDIN after I gave it EOF (^D on Unix, ^Z on MS-DOS)?
.IP \(bu 4
How can I convert my shell script to perl?
.IP \(bu 4
Can I use perl to run a telnet or ftp session?
.IP \(bu 4
How can I write expect in Perl?
.IP \(bu 4
Is there a way to hide perl's command line from programs such as "ps"?
.IP \(bu 4
I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?
.IP \(bu 4
How do I close a process's filehandle without waiting for it to complete?
.IP \(bu 4
How do I fork a daemon process?
.IP \(bu 4
How do I find out if I'm running interactively or not?
.IP \(bu 4
How do I timeout a slow event?
.IP \(bu 4
How do I set CPU limits?
.IP \(bu 4
How do I avoid zombies on a Unix system?
.IP \(bu 4
How do I use an SQL database?
.IP \(bu 4
How do I make a \fBsystem()\fR exit on control-C?
.IP \(bu 4
How do I open a file without blocking?
.IP \(bu 4
How do I tell the difference between errors from the shell and perl?
.IP \(bu 4
How do I install a module from CPAN?
.IP \(bu 4
What's the difference between require and use?
.IP \(bu 4
How do I keep my own module/library directory?
.IP \(bu 4
How do I add the directory my program lives in to the module/library search path?
.IP \(bu 4
How do I add a directory to my include path (@INC) at runtime?
.IP \(bu 4
Where are modules installed?
.IP \(bu 4
What is socket.ph and where do I get it?
.SS "perlfaq9: Web, Email and Networking"
.IX Subsection "perlfaq9: Web, Email and Networking"
This section deals with questions related to running web sites, sending and receiving email as well as general networking.
.IP \(bu 4
Should I use a web framework?
.IP \(bu 4
Which web framework should I use?
.IP \(bu 4
What is Plack and PSGI?
.IP \(bu 4
How do I remove HTML from a string?
.IP \(bu 4
How do I extract URLs?
.IP \(bu 4
How do I fetch an HTML file?
.IP \(bu 4
How do I automate an HTML form submission?
.IP \(bu 4
How do I decode or create those %\-encodings on the web?
.IP \(bu 4
How do I redirect to another page?
.IP \(bu 4
How do I put a password on my web pages?
.IP \(bu 4
How do I make sure users can't enter values into a form that causes my CGI script to do bad things?
.IP \(bu 4
How do I parse a mail header?
.IP \(bu 4
How do I check a valid mail address?
.IP \(bu 4
How do I decode a MIME/BASE64 string?
.IP \(bu 4
How do I find the user's mail address?
.IP \(bu 4
How do I send email?
.IP \(bu 4
How do I use MIME to make an attachment to a mail message?
.IP \(bu 4
How do I read email?
.IP \(bu 4
How do I find out my hostname, domainname, or IP address?
.IP \(bu 4
How do I fetch/put an (S)FTP file?
.IP \(bu 4
How can I do RPC in Perl?
.SH CREDITS
.IX Header "CREDITS"
Tom Christiansen wrote the original perlfaq then expanded it with the
help of Nat Torkington. brian d foy substantially edited and expanded
the perlfaq. perlfaq-workers and others have also supplied feedback,
patches and corrections over the years.
.SH "AUTHOR AND COPYRIGHT"
.IX Header "AUTHOR AND COPYRIGHT"
Tom Christiansen wrote the original version of this document.
brian d foy \f(CW\*(C`<bdfoy@cpan.org>\*(C'\fR wrote this version. See the
individual perlfaq documents for additional copyright information.
.PP
This document is available under the same terms as Perl itself. Code
examples in all the perlfaq documents are in the public domain. Use
them as you see fit (and at your own risk with no warranty from anyone).
|