Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "PERLFAQ 1" | |
132 | .TH PERLFAQ 1 "2002-06-08" "perl v5.8.0" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | perlfaq \- frequently asked questions about Perl ($Date: 2002/03/11 21:32:23 $) | |
135 | .SH "DESCRIPTION" | |
136 | .IX Header "DESCRIPTION" | |
137 | The perlfaq is structured into the following documents: | |
138 | .Sh "perlfaq: Structural overview of the \s-1FAQ\s0." | |
139 | .IX Subsection "perlfaq: Structural overview of the FAQ." | |
140 | This document. | |
141 | .Sh "perlfaq1: General Questions About Perl" | |
142 | .IX Subsection "perlfaq1: General Questions About Perl" | |
143 | Very general, high-level questions about Perl. | |
144 | .IP "\(bu" 4 | |
145 | What is Perl? | |
146 | .IP "\(bu" 4 | |
147 | Who supports Perl? Who develops it? Why is it free? | |
148 | .IP "\(bu" 4 | |
149 | Which version of Perl should I use? | |
150 | .IP "\(bu" 4 | |
151 | What are perl4 and perl5? | |
152 | .IP "\(bu" 4 | |
153 | What is perl6? | |
154 | .IP "\(bu" 4 | |
155 | How stable is Perl? | |
156 | .IP "\(bu" 4 | |
157 | Is Perl difficult to learn? | |
158 | .IP "\(bu" 4 | |
159 | How does Perl compare with other languages like Java, Python, \s-1REXX\s0, Scheme, or Tcl? | |
160 | .IP "\(bu" 4 | |
161 | Can I do [task] in Perl? | |
162 | .IP "\(bu" 4 | |
163 | When shouldn't I program in Perl? | |
164 | .IP "\(bu" 4 | |
165 | What's the difference between \*(L"perl\*(R" and \*(L"Perl\*(R"? | |
166 | .IP "\(bu" 4 | |
167 | Is it a Perl program or a Perl script? | |
168 | .IP "\(bu" 4 | |
169 | What is a \s-1JAPH\s0? | |
170 | .IP "\(bu" 4 | |
171 | Where can I get a list of Larry Wall witticisms? | |
172 | .IP "\(bu" 4 | |
173 | How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language? | |
174 | .Sh "perlfaq2: Obtaining and Learning about Perl" | |
175 | .IX Subsection "perlfaq2: Obtaining and Learning about Perl" | |
176 | Where to find source and documentation for Perl, support, | |
177 | and related matters. | |
178 | .IP "\(bu" 4 | |
179 | What machines support Perl? Where do I get it? | |
180 | .IP "\(bu" 4 | |
181 | How can I get a binary version of Perl? | |
182 | .IP "\(bu" 4 | |
183 | I don't have a C compiler on my system. How can I compile perl? | |
184 | .IP "\(bu" 4 | |
185 | I copied the Perl binary from one machine to another, but scripts don't work. | |
186 | .IP "\(bu" 4 | |
187 | I grabbed the sources and tried to compile but gdbm/dynamic loading/malloc/linking/... failed. How do I make it work? | |
188 | .IP "\(bu" 4 | |
189 | What modules and extensions are available for Perl? What is \s-1CPAN\s0? What does CPAN/src/... mean? | |
190 | .IP "\(bu" 4 | |
191 | Is there an \s-1ISO\s0 or \s-1ANSI\s0 certified version of Perl? | |
192 | .IP "\(bu" 4 | |
193 | Where can I get information on Perl? | |
194 | .IP "\(bu" 4 | |
195 | What are the Perl newsgroups on Usenet? Where do I post questions? | |
196 | .IP "\(bu" 4 | |
197 | Where should I post source code? | |
198 | .IP "\(bu" 4 | |
199 | Perl Books | |
200 | .IP "\(bu" 4 | |
201 | Perl in Magazines | |
202 | .IP "\(bu" 4 | |
203 | Perl on the Net: \s-1FTP\s0 and \s-1WWW\s0 Access | |
204 | .IP "\(bu" 4 | |
205 | What mailing lists are there for Perl? | |
206 | .IP "\(bu" 4 | |
207 | Archives of comp.lang.perl.misc | |
208 | .IP "\(bu" 4 | |
209 | Where can I buy a commercial version of Perl? | |
210 | .IP "\(bu" 4 | |
211 | Where do I send bug reports? | |
212 | .IP "\(bu" 4 | |
213 | What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? | |
214 | .Sh "perlfaq3: Programming Tools" | |
215 | .IX Subsection "perlfaq3: Programming Tools" | |
216 | Programmer tools and programming support. | |
217 | .IP "\(bu" 4 | |
218 | How do I do (anything)? | |
219 | .IP "\(bu" 4 | |
220 | How can I use Perl interactively? | |
221 | .IP "\(bu" 4 | |
222 | Is there a Perl shell? | |
223 | .IP "\(bu" 4 | |
224 | How do I debug my Perl programs? | |
225 | .IP "\(bu" 4 | |
226 | How do I profile my Perl programs? | |
227 | .IP "\(bu" 4 | |
228 | How do I cross-reference my Perl programs? | |
229 | .IP "\(bu" 4 | |
230 | Is there a pretty-printer (formatter) for Perl? | |
231 | .IP "\(bu" 4 | |
232 | Is there a ctags for Perl? | |
233 | .IP "\(bu" 4 | |
234 | Is there an \s-1IDE\s0 or Windows Perl Editor? | |
235 | .IP "\(bu" 4 | |
236 | Where can I get Perl macros for vi? | |
237 | .IP "\(bu" 4 | |
238 | Where can I get perl-mode for emacs? | |
239 | .IP "\(bu" 4 | |
240 | How can I use curses with Perl? | |
241 | .IP "\(bu" 4 | |
242 | How can I use X or Tk with Perl? | |
243 | .IP "\(bu" 4 | |
244 | How can I generate simple menus without using \s-1CGI\s0 or Tk? | |
245 | .IP "\(bu" 4 | |
246 | How can I make my Perl program run faster? | |
247 | .IP "\(bu" 4 | |
248 | How can I make my Perl program take less memory? | |
249 | .IP "\(bu" 4 | |
250 | Is it unsafe to return a pointer to local data? | |
251 | .IP "\(bu" 4 | |
252 | How can I free an array or hash so my program shrinks? | |
253 | .IP "\(bu" 4 | |
254 | How can I make my \s-1CGI\s0 script more efficient? | |
255 | .IP "\(bu" 4 | |
256 | How can I hide the source for my Perl program? | |
257 | .IP "\(bu" 4 | |
258 | How can I compile my Perl program into byte code or C? | |
259 | .IP "\(bu" 4 | |
260 | How can I compile Perl into Java? | |
261 | .IP "\(bu" 4 | |
262 | How can I get \f(CW\*(C`#!perl\*(C'\fR to work on [\s-1MS\-DOS\s0,NT,...]? | |
263 | .IP "\(bu" 4 | |
264 | Can I write useful Perl programs on the command line? | |
265 | .IP "\(bu" 4 | |
266 | Why don't Perl one-liners work on my DOS/Mac/VMS system? | |
267 | .IP "\(bu" 4 | |
268 | Where can I learn about \s-1CGI\s0 or Web programming in Perl? | |
269 | .IP "\(bu" 4 | |
270 | Where can I learn about object-oriented Perl programming? | |
271 | .IP "\(bu" 4 | |
272 | Where can I learn about linking C with Perl? [h2xs, xsubpp] | |
273 | .IP "\(bu" 4 | |
274 | I've read perlembed, perlguts, etc., but I can't embed perl in | |
275 | my C program; what am I doing wrong? | |
276 | .IP "\(bu" 4 | |
277 | When I tried to run my script, I got this message. What does it mean? | |
278 | .IP "\(bu" 4 | |
279 | What's MakeMaker? | |
280 | .Sh "perlfaq4: Data Manipulation" | |
281 | .IX Subsection "perlfaq4: Data Manipulation" | |
282 | Manipulating numbers, dates, strings, arrays, hashes, and | |
283 | miscellaneous data issues. | |
284 | .IP "\(bu" 4 | |
285 | Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)? | |
286 | .IP "\(bu" 4 | |
287 | Why isn't my octal data interpreted correctly? | |
288 | .IP "\(bu" 4 | |
289 | Does Perl have a \fIround()\fR function? What about \fIceil()\fR and \fIfloor()\fR? Trig functions? | |
290 | .IP "\(bu" 4 | |
291 | How do I convert between numeric representations? | |
292 | .IP "\(bu" 4 | |
293 | Why doesn't & work the way I want it to? | |
294 | .IP "\(bu" 4 | |
295 | How do I multiply matrices? | |
296 | .IP "\(bu" 4 | |
297 | How do I perform an operation on a series of integers? | |
298 | .IP "\(bu" 4 | |
299 | How can I output Roman numerals? | |
300 | .IP "\(bu" 4 | |
301 | Why aren't my random numbers random? | |
302 | .IP "\(bu" 4 | |
303 | How do I get a random number between X and Y? | |
304 | .IP "\(bu" 4 | |
305 | How do I find the week\-of\-the\-year/day\-of\-the\-year? | |
306 | .IP "\(bu" 4 | |
307 | How do I find the current century or millennium? | |
308 | .IP "\(bu" 4 | |
309 | How can I compare two dates and find the difference? | |
310 | .IP "\(bu" 4 | |
311 | How can I take a string and turn it into epoch seconds? | |
312 | .IP "\(bu" 4 | |
313 | How can I find the Julian Day? | |
314 | .IP "\(bu" 4 | |
315 | How do I find yesterday's date? | |
316 | .IP "\(bu" 4 | |
317 | Does Perl have a Year 2000 problem? Is Perl Y2K compliant? | |
318 | .IP "\(bu" 4 | |
319 | How do I validate input? | |
320 | .IP "\(bu" 4 | |
321 | How do I unescape a string? | |
322 | .IP "\(bu" 4 | |
323 | How do I remove consecutive pairs of characters? | |
324 | .IP "\(bu" 4 | |
325 | How do I expand function calls in a string? | |
326 | .IP "\(bu" 4 | |
327 | How do I find matching/nesting anything? | |
328 | .IP "\(bu" 4 | |
329 | How do I reverse a string? | |
330 | .IP "\(bu" 4 | |
331 | How do I expand tabs in a string? | |
332 | .IP "\(bu" 4 | |
333 | How do I reformat a paragraph? | |
334 | .IP "\(bu" 4 | |
335 | How can I access/change the first N letters of a string? | |
336 | .IP "\(bu" 4 | |
337 | How do I change the Nth occurrence of something? | |
338 | .IP "\(bu" 4 | |
339 | How can I count the number of occurrences of a substring within a string? | |
340 | .IP "\(bu" 4 | |
341 | How do I capitalize all the words on one line? | |
342 | .IP "\(bu" 4 | |
343 | How can I split a [character] delimited string except when inside | |
344 | [character]? (Comma\-separated files) | |
345 | .IP "\(bu" 4 | |
346 | How do I strip blank space from the beginning/end of a string? | |
347 | .IP "\(bu" 4 | |
348 | How do I pad a string with blanks or pad a number with zeroes? | |
349 | .IP "\(bu" 4 | |
350 | How do I extract selected columns from a string? | |
351 | .IP "\(bu" 4 | |
352 | How do I find the soundex value of a string? | |
353 | .IP "\(bu" 4 | |
354 | How can I expand variables in text strings? | |
355 | .IP "\(bu" 4 | |
356 | What's wrong with always quoting \*(L"$vars\*(R"? | |
357 | .IP "\(bu" 4 | |
358 | Why don't my <<\s-1HERE\s0 documents work? | |
359 | .IP "\(bu" 4 | |
360 | What is the difference between a list and an array? | |
361 | .IP "\(bu" 4 | |
362 | What is the difference between \f(CW$array\fR[1] and \f(CW@array\fR[1]? | |
363 | .IP "\(bu" 4 | |
364 | How can I remove duplicate elements from a list or array? | |
365 | .IP "\(bu" 4 | |
366 | How can I tell whether a certain element is contained in a list or array? | |
367 | .IP "\(bu" 4 | |
368 | How do I compute the difference of two arrays? How do I compute the intersection of two arrays? | |
369 | .IP "\(bu" 4 | |
370 | How do I test whether two arrays or hashes are equal? | |
371 | .IP "\(bu" 4 | |
372 | How do I find the first array element for which a condition is true? | |
373 | .IP "\(bu" 4 | |
374 | How do I handle linked lists? | |
375 | .IP "\(bu" 4 | |
376 | How do I handle circular lists? | |
377 | .IP "\(bu" 4 | |
378 | How do I shuffle an array randomly? | |
379 | .IP "\(bu" 4 | |
380 | How do I process/modify each element of an array? | |
381 | .IP "\(bu" 4 | |
382 | How do I select a random element from an array? | |
383 | .IP "\(bu" 4 | |
384 | How do I permute N elements of a list? | |
385 | .IP "\(bu" 4 | |
386 | How do I sort an array by (anything)? | |
387 | .IP "\(bu" 4 | |
388 | How do I manipulate arrays of bits? | |
389 | .IP "\(bu" 4 | |
390 | Why does \fIdefined()\fR return true on empty arrays and hashes? | |
391 | .IP "\(bu" 4 | |
392 | How do I process an entire hash? | |
393 | .IP "\(bu" 4 | |
394 | What happens if I add or remove keys from a hash while iterating over it? | |
395 | .IP "\(bu" 4 | |
396 | How do I look up a hash element by value? | |
397 | .IP "\(bu" 4 | |
398 | How can I know how many entries are in a hash? | |
399 | .IP "\(bu" 4 | |
400 | How do I sort a hash (optionally by value instead of key)? | |
401 | .IP "\(bu" 4 | |
402 | How can I always keep my hash sorted? | |
403 | .IP "\(bu" 4 | |
404 | What's the difference between \*(L"delete\*(R" and \*(L"undef\*(R" with hashes? | |
405 | .IP "\(bu" 4 | |
406 | Why don't my tied hashes make the defined/exists distinction? | |
407 | .IP "\(bu" 4 | |
408 | How do I reset an \fIeach()\fR operation part-way through? | |
409 | .IP "\(bu" 4 | |
410 | How can I get the unique keys from two hashes? | |
411 | .IP "\(bu" 4 | |
412 | How can I store a multidimensional array in a \s-1DBM\s0 file? | |
413 | .IP "\(bu" 4 | |
414 | How can I make my hash remember the order I put elements into it? | |
415 | .IP "\(bu" 4 | |
416 | Why does passing a subroutine an undefined element in a hash create it? | |
417 | .IP "\(bu" 4 | |
418 | How can I make the Perl equivalent of a C structure/\*(C+ class/hash or array of hashes or arrays? | |
419 | .IP "\(bu" 4 | |
420 | How can I use a reference as a hash key? | |
421 | .IP "\(bu" 4 | |
422 | How do I handle binary data correctly? | |
423 | .IP "\(bu" 4 | |
424 | How do I determine whether a scalar is a number/whole/integer/float? | |
425 | .IP "\(bu" 4 | |
426 | How do I keep persistent data across program calls? | |
427 | .IP "\(bu" 4 | |
428 | How do I print out or copy a recursive data structure? | |
429 | .IP "\(bu" 4 | |
430 | How do I define methods for every class/object? | |
431 | .IP "\(bu" 4 | |
432 | How do I verify a credit card checksum? | |
433 | .IP "\(bu" 4 | |
434 | How do I pack arrays of doubles or floats for \s-1XS\s0 code? | |
435 | .Sh "perlfaq5: Files and Formats" | |
436 | .IX Subsection "perlfaq5: Files and Formats" | |
437 | I/O and the \*(L"f\*(R" issues: filehandles, flushing, formats, and footers. | |
438 | .IP "\(bu" 4 | |
439 | How do I flush/unbuffer an output filehandle? Why must I do this? | |
440 | .IP "\(bu" 4 | |
441 | How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file? | |
442 | .IP "\(bu" 4 | |
443 | How do I count the number of lines in a file? | |
444 | .IP "\(bu" 4 | |
445 | How do I make a temporary file name? | |
446 | .IP "\(bu" 4 | |
447 | How can I manipulate fixed-record-length files? | |
448 | .IP "\(bu" 4 | |
449 | 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? | |
450 | .IP "\(bu" 4 | |
451 | How can I use a filehandle indirectly? | |
452 | .IP "\(bu" 4 | |
453 | How can I set up a footer format to be used with \fIwrite()\fR? | |
454 | .IP "\(bu" 4 | |
455 | How can I \fIwrite()\fR into a string? | |
456 | .IP "\(bu" 4 | |
457 | How can I output my numbers with commas added? | |
458 | .IP "\(bu" 4 | |
459 | How can I translate tildes (~) in a filename? | |
460 | .IP "\(bu" 4 | |
461 | How come when I open a file read-write it wipes it out? | |
462 | .IP "\(bu" 4 | |
463 | Why do I sometimes get an \*(L"Argument list too long\*(R" when I use <*>? | |
464 | .IP "\(bu" 4 | |
465 | Is there a leak/bug in \fIglob()\fR? | |
466 | .IP "\(bu" 4 | |
467 | How can I open a file with a leading \*(L">\*(R" or trailing blanks? | |
468 | .IP "\(bu" 4 | |
469 | How can I reliably rename a file? | |
470 | .IP "\(bu" 4 | |
471 | How can I lock a file? | |
472 | .IP "\(bu" 4 | |
473 | Why can't I just open(\s-1FH\s0, \*(L">file.lock\*(R")? | |
474 | .IP "\(bu" 4 | |
475 | I still don't get locking. I just want to increment the number in the file. How can I do this? | |
476 | .IP "\(bu" 4 | |
477 | 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? | |
478 | .IP "\(bu" 4 | |
479 | How do I randomly update a binary file? | |
480 | .IP "\(bu" 4 | |
481 | How do I get a file's timestamp in perl? | |
482 | .IP "\(bu" 4 | |
483 | How do I set a file's timestamp in perl? | |
484 | .IP "\(bu" 4 | |
485 | How do I print to more than one file at once? | |
486 | .IP "\(bu" 4 | |
487 | How can I read in an entire file all at once? | |
488 | .IP "\(bu" 4 | |
489 | How can I read in a file by paragraphs? | |
490 | .IP "\(bu" 4 | |
491 | How can I read a single character from a file? From the keyboard? | |
492 | .IP "\(bu" 4 | |
493 | How can I tell whether there's a character waiting on a filehandle? | |
494 | .IP "\(bu" 4 | |
495 | How do I do a \f(CW\*(C`tail \-f\*(C'\fR in perl? | |
496 | .IP "\(bu" 4 | |
497 | How do I \fIdup()\fR a filehandle in Perl? | |
498 | .IP "\(bu" 4 | |
499 | How do I close a file descriptor by number? | |
500 | .IP "\(bu" 4 | |
501 | Why can't I use \*(L"C:\etemp\efoo\*(R" in \s-1DOS\s0 paths? What doesn't `C:\etemp\efoo.exe` work? | |
502 | .IP "\(bu" 4 | |
503 | Why doesn't glob(\*(L"*.*\*(R") get all the files? | |
504 | .IP "\(bu" 4 | |
505 | 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? | |
506 | .IP "\(bu" 4 | |
507 | How do I select a random line from a file? | |
508 | .IP "\(bu" 4 | |
509 | Why do I get weird spaces when I print an array of lines? | |
510 | .Sh "perlfaq6: Regular Expressions" | |
511 | .IX Subsection "perlfaq6: Regular Expressions" | |
512 | Pattern matching and regular expressions. | |
513 | .IP "\(bu" 4 | |
514 | How can I hope to use regular expressions without creating illegible and unmaintainable code? | |
515 | .IP "\(bu" 4 | |
516 | I'm having trouble matching over more than one line. What's wrong? | |
517 | .IP "\(bu" 4 | |
518 | How can I pull out lines between two patterns that are themselves on different lines? | |
519 | .IP "\(bu" 4 | |
520 | I put a regular expression into $/ but it didn't work. What's wrong? | |
521 | .IP "\(bu" 4 | |
522 | How do I substitute case insensitively on the \s-1LHS\s0 while preserving case on the \s-1RHS\s0? | |
523 | .IP "\(bu" 4 | |
524 | How can I make \f(CW\*(C`\ew\*(C'\fR match national character sets? | |
525 | .IP "\(bu" 4 | |
526 | How can I match a locale-smart version of \f(CW\*(C`/[a\-zA\-Z]/\*(C'\fR? | |
527 | .IP "\(bu" 4 | |
528 | How can I quote a variable to use in a regex? | |
529 | .IP "\(bu" 4 | |
530 | What is \f(CW\*(C`/o\*(C'\fR really for? | |
531 | .IP "\(bu" 4 | |
532 | How do I use a regular expression to strip C style comments from a file? | |
533 | .IP "\(bu" 4 | |
534 | Can I use Perl regular expressions to match balanced text? | |
535 | .IP "\(bu" 4 | |
536 | What does it mean that regexes are greedy? How can I get around it? | |
537 | .IP "\(bu" 4 | |
538 | How do I process each word on each line? | |
539 | .IP "\(bu" 4 | |
540 | How can I print out a word-frequency or line-frequency summary? | |
541 | .IP "\(bu" 4 | |
542 | How can I do approximate matching? | |
543 | .IP "\(bu" 4 | |
544 | How do I efficiently match many regular expressions at once? | |
545 | .IP "\(bu" 4 | |
546 | Why don't word-boundary searches with \f(CW\*(C`\eb\*(C'\fR work for me? | |
547 | .IP "\(bu" 4 | |
548 | Why does using $&, $`, or $' slow my program down? | |
549 | .IP "\(bu" 4 | |
550 | What good is \f(CW\*(C`\eG\*(C'\fR in a regular expression? | |
551 | .IP "\(bu" 4 | |
552 | Are Perl regexes DFAs or NFAs? Are they \s-1POSIX\s0 compliant? | |
553 | .IP "\(bu" 4 | |
554 | What's wrong with using grep or map in a void context? | |
555 | .IP "\(bu" 4 | |
556 | How can I match strings with multibyte characters? | |
557 | .IP "\(bu" 4 | |
558 | How do I match a pattern that is supplied by the user? | |
559 | .Sh "perlfaq7: General Perl Language Issues" | |
560 | .IX Subsection "perlfaq7: General Perl Language Issues" | |
561 | General Perl language issues that don't clearly fit into any of the | |
562 | other sections. | |
563 | .IP "\(bu" 4 | |
564 | Can I get a BNF/yacc/RE for the Perl language? | |
565 | .IP "\(bu" 4 | |
566 | What are all these $@%&* punctuation signs, and how do I know when to use them? | |
567 | .IP "\(bu" 4 | |
568 | Do I always/never have to quote my strings or use semicolons and commas? | |
569 | .IP "\(bu" 4 | |
570 | How do I skip some return values? | |
571 | .IP "\(bu" 4 | |
572 | How do I temporarily block warnings? | |
573 | .IP "\(bu" 4 | |
574 | What's an extension? | |
575 | .IP "\(bu" 4 | |
576 | Why do Perl operators have different precedence than C operators? | |
577 | .IP "\(bu" 4 | |
578 | How do I declare/create a structure? | |
579 | .IP "\(bu" 4 | |
580 | How do I create a module? | |
581 | .IP "\(bu" 4 | |
582 | How do I create a class? | |
583 | .IP "\(bu" 4 | |
584 | How can I tell if a variable is tainted? | |
585 | .IP "\(bu" 4 | |
586 | What's a closure? | |
587 | .IP "\(bu" 4 | |
588 | What is variable suicide and how can I prevent it? | |
589 | .IP "\(bu" 4 | |
590 | How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}? | |
591 | .IP "\(bu" 4 | |
592 | How do I create a static variable? | |
593 | .IP "\(bu" 4 | |
594 | What's the difference between dynamic and lexical (static) scoping? Between \fIlocal()\fR and \fImy()\fR? | |
595 | .IP "\(bu" 4 | |
596 | How can I access a dynamic variable while a similarly named lexical is in scope? | |
597 | .IP "\(bu" 4 | |
598 | What's the difference between deep and shallow binding? | |
599 | .IP "\(bu" 4 | |
600 | Why doesn't \*(L"my($foo) = <\s-1FILE\s0>;\*(R" work right? | |
601 | .IP "\(bu" 4 | |
602 | How do I redefine a builtin function, operator, or method? | |
603 | .IP "\(bu" 4 | |
604 | What's the difference between calling a function as &foo and \fIfoo()\fR? | |
605 | .IP "\(bu" 4 | |
606 | How do I create a switch or case statement? | |
607 | .IP "\(bu" 4 | |
608 | How can I catch accesses to undefined variables/functions/methods? | |
609 | .IP "\(bu" 4 | |
610 | Why can't a method included in this same file be found? | |
611 | .IP "\(bu" 4 | |
612 | How can I find out my current package? | |
613 | .IP "\(bu" 4 | |
614 | How can I comment out a large block of perl code? | |
615 | .IP "\(bu" 4 | |
616 | How do I clear a package? | |
617 | .IP "\(bu" 4 | |
618 | How can I use a variable as a variable name? | |
619 | .Sh "perlfaq8: System Interaction" | |
620 | .IX Subsection "perlfaq8: System Interaction" | |
621 | Interprocess communication (\s-1IPC\s0), control over the user-interface | |
622 | (keyboard, screen and pointing devices). | |
623 | .IP "\(bu" 4 | |
624 | How do I find out which operating system I'm running under? | |
625 | .IP "\(bu" 4 | |
626 | How come \fIexec()\fR doesn't return? | |
627 | .IP "\(bu" 4 | |
628 | How do I do fancy stuff with the keyboard/screen/mouse? | |
629 | .IP "\(bu" 4 | |
630 | How do I print something out in color? | |
631 | .IP "\(bu" 4 | |
632 | How do I read just one key without waiting for a return key? | |
633 | .IP "\(bu" 4 | |
634 | How do I check whether input is ready on the keyboard? | |
635 | .IP "\(bu" 4 | |
636 | How do I clear the screen? | |
637 | .IP "\(bu" 4 | |
638 | How do I get the screen size? | |
639 | .IP "\(bu" 4 | |
640 | How do I ask the user for a password? | |
641 | .IP "\(bu" 4 | |
642 | How do I read and write the serial port? | |
643 | .IP "\(bu" 4 | |
644 | How do I decode encrypted password files? | |
645 | .IP "\(bu" 4 | |
646 | How do I start a process in the background? | |
647 | .IP "\(bu" 4 | |
648 | How do I trap control characters/signals? | |
649 | .IP "\(bu" 4 | |
650 | How do I modify the shadow password file on a Unix system? | |
651 | .IP "\(bu" 4 | |
652 | How do I set the time and date? | |
653 | .IP "\(bu" 4 | |
654 | How can I \fIsleep()\fR or \fIalarm()\fR for under a second? | |
655 | .IP "\(bu" 4 | |
656 | How can I measure time under a second? | |
657 | .IP "\(bu" 4 | |
658 | How can I do an \fIatexit()\fR or \fIsetjmp()\fR/\fIlongjmp()\fR? (Exception handling) | |
659 | .IP "\(bu" 4 | |
660 | Why doesn't my sockets program work under System V (Solaris)? What does the error message \*(L"Protocol not supported\*(R" mean? | |
661 | .IP "\(bu" 4 | |
662 | How can I call my system's unique C functions from Perl? | |
663 | .IP "\(bu" 4 | |
664 | Where do I get the include files to do \fIioctl()\fR or \fIsyscall()\fR? | |
665 | .IP "\(bu" 4 | |
666 | Why do setuid perl scripts complain about kernel problems? | |
667 | .IP "\(bu" 4 | |
668 | How can I open a pipe both to and from a command? | |
669 | .IP "\(bu" 4 | |
670 | Why can't I get the output of a command with \fIsystem()\fR? | |
671 | .IP "\(bu" 4 | |
672 | How can I capture \s-1STDERR\s0 from an external command? | |
673 | .IP "\(bu" 4 | |
674 | Why doesn't \fIopen()\fR return an error when a pipe open fails? | |
675 | .IP "\(bu" 4 | |
676 | What's wrong with using backticks in a void context? | |
677 | .IP "\(bu" 4 | |
678 | How can I call backticks without shell processing? | |
679 | .IP "\(bu" 4 | |
680 | Why can't my script read from \s-1STDIN\s0 after I gave it \s-1EOF\s0 (^D on Unix, ^Z on \s-1MS\-DOS\s0)? | |
681 | .IP "\(bu" 4 | |
682 | How can I convert my shell script to perl? | |
683 | .IP "\(bu" 4 | |
684 | Can I use perl to run a telnet or ftp session? | |
685 | .IP "\(bu" 4 | |
686 | How can I write expect in Perl? | |
687 | .IP "\(bu" 4 | |
688 | Is there a way to hide perl's command line from programs such as \*(L"ps\*(R"? | |
689 | .IP "\(bu" 4 | |
690 | 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? | |
691 | .IP "\(bu" 4 | |
692 | How do I close a process's filehandle without waiting for it to complete? | |
693 | .IP "\(bu" 4 | |
694 | How do I fork a daemon process? | |
695 | .IP "\(bu" 4 | |
696 | How do I find out if I'm running interactively or not? | |
697 | .IP "\(bu" 4 | |
698 | How do I timeout a slow event? | |
699 | .IP "\(bu" 4 | |
700 | How do I set \s-1CPU\s0 limits? | |
701 | .IP "\(bu" 4 | |
702 | How do I avoid zombies on a Unix system? | |
703 | .IP "\(bu" 4 | |
704 | How do I use an \s-1SQL\s0 database? | |
705 | .IP "\(bu" 4 | |
706 | How do I make a \fIsystem()\fR exit on control\-C? | |
707 | .IP "\(bu" 4 | |
708 | How do I open a file without blocking? | |
709 | .IP "\(bu" 4 | |
710 | How do I install a module from \s-1CPAN\s0? | |
711 | .IP "\(bu" 4 | |
712 | What's the difference between require and use? | |
713 | .IP "\(bu" 4 | |
714 | How do I keep my own module/library directory? | |
715 | .IP "\(bu" 4 | |
716 | How do I add the directory my program lives in to the module/library search path? | |
717 | .IP "\(bu" 4 | |
718 | How do I add a directory to my include path at runtime? | |
719 | .IP "\(bu" 4 | |
720 | What is socket.ph and where do I get it? | |
721 | .Sh "perlfaq9: Networking" | |
722 | .IX Subsection "perlfaq9: Networking" | |
723 | Networking, the internet, and a few on the web. | |
724 | .IP "\(bu" 4 | |
725 | What is the correct form of response from a \s-1CGI\s0 script? | |
726 | .IP "\(bu" 4 | |
727 | My \s-1CGI\s0 script runs from the command line but not the browser. (500 Server Error) | |
728 | .IP "\(bu" 4 | |
729 | How can I get better error messages from a \s-1CGI\s0 program? | |
730 | .IP "\(bu" 4 | |
731 | How do I remove \s-1HTML\s0 from a string? | |
732 | .IP "\(bu" 4 | |
733 | How do I extract URLs? | |
734 | .IP "\(bu" 4 | |
735 | How do I download a file from the user's machine? How do I open a file on another machine? | |
736 | .IP "\(bu" 4 | |
737 | How do I make a pop-up menu in \s-1HTML\s0? | |
738 | .IP "\(bu" 4 | |
739 | How do I fetch an \s-1HTML\s0 file? | |
740 | .IP "\(bu" 4 | |
741 | How do I automate an \s-1HTML\s0 form submission? | |
742 | .IP "\(bu" 4 | |
743 | How do I decode or create those %\-encodings on the web? | |
744 | .IP "\(bu" 4 | |
745 | How do I redirect to another page? | |
746 | .IP "\(bu" 4 | |
747 | How do I put a password on my web pages? | |
748 | .IP "\(bu" 4 | |
749 | How do I edit my .htpasswd and .htgroup files with Perl? | |
750 | .IP "\(bu" 4 | |
751 | How do I make sure users can't enter values into a form that cause my \s-1CGI\s0 script to do bad things? | |
752 | .IP "\(bu" 4 | |
753 | How do I parse a mail header? | |
754 | .IP "\(bu" 4 | |
755 | How do I decode a \s-1CGI\s0 form? | |
756 | .IP "\(bu" 4 | |
757 | How do I check a valid mail address? | |
758 | .IP "\(bu" 4 | |
759 | How do I decode a \s-1MIME/BASE64\s0 string? | |
760 | .IP "\(bu" 4 | |
761 | How do I return the user's mail address? | |
762 | .IP "\(bu" 4 | |
763 | How do I send mail? | |
764 | .IP "\(bu" 4 | |
765 | How do I use \s-1MIME\s0 to make an attachment to a mail message? | |
766 | .IP "\(bu" 4 | |
767 | How do I read mail? | |
768 | .IP "\(bu" 4 | |
769 | How do I find out my hostname/domainname/IP address? | |
770 | .IP "\(bu" 4 | |
771 | How do I fetch a news article or the active newsgroups? | |
772 | .IP "\(bu" 4 | |
773 | How do I fetch/put an \s-1FTP\s0 file? | |
774 | .IP "\(bu" 4 | |
775 | How can I do \s-1RPC\s0 in Perl? | |
776 | .SH "About the perlfaq documents" | |
777 | .IX Header "About the perlfaq documents" | |
778 | .Sh "Where to get the perlfaq" | |
779 | .IX Subsection "Where to get the perlfaq" | |
780 | This document is posted regularly to comp.lang.perl.announce and | |
781 | several other related newsgroups. It is available on many | |
782 | web sites: http://www.perldoc.com/ and http://perlfaq.cpan.org/ . | |
783 | .Sh "How to contribute to the perlfaq" | |
784 | .IX Subsection "How to contribute to the perlfaq" | |
785 | You may mail corrections, additions, and suggestions to | |
786 | perlfaq\-workers@perl.org . This alias should not be | |
787 | used to \fIask\fR FAQs. It's for fixing the current \s-1FAQ\s0. | |
788 | Send questions to the comp.lang.perl.misc newsgroup. | |
789 | .Sh "What will happen if you mail your Perl programming problems to the authors" | |
790 | .IX Subsection "What will happen if you mail your Perl programming problems to the authors" | |
791 | Your questions will probably go unread, unless they're suggestions of | |
792 | new questions to add to the \s-1FAQ\s0, in which case they should have gone | |
793 | to the perlfaq\-workers@perl.org instead. | |
794 | .PP | |
795 | You should have read section 2 of this faq. There you would have | |
796 | learned that comp.lang.perl.misc is the appropriate place to go for | |
797 | free advice. If your question is really important and you require a | |
798 | prompt and correct answer, you should hire a consultant. | |
799 | .SH "Credits" | |
800 | .IX Header "Credits" | |
801 | When I first began the Perl \s-1FAQ\s0 in the late 80s, I never realized it | |
802 | would have grown to over a hundred pages, nor that Perl would ever become | |
803 | so popular and widespread. This document could not have been written | |
804 | without the tremendous help provided by Larry Wall and the rest of the | |
805 | Perl Porters. | |
806 | .SH "Author and Copyright Information" | |
807 | .IX Header "Author and Copyright Information" | |
808 | Copyright (c) 1997\-2002 Tom Christiansen and Nathan Torkington. | |
809 | All rights reserved. | |
810 | .Sh "Bundled Distributions" | |
811 | .IX Subsection "Bundled Distributions" | |
812 | This documentation is free; you can redistribute it and/or modify it | |
813 | under the same terms as Perl itself. | |
814 | .PP | |
815 | Irrespective of its distribution, all code examples in these files | |
816 | are hereby placed into the public domain. You are permitted and | |
817 | encouraged to use this code in your own programs for fun | |
818 | or for profit as you see fit. A simple comment in the code giving | |
819 | credit would be courteous but is not required. | |
820 | .Sh "Disclaimer" | |
821 | .IX Subsection "Disclaimer" | |
822 | This information is offered in good faith and in the hope that it may | |
823 | be of use, but is not guaranteed to be correct, up to date, or suitable | |
824 | for any particular purpose whatsoever. The authors accept no liability | |
825 | in respect of this information or its use. | |
826 | .SH "Changes" | |
827 | .IX Header "Changes" | |
828 | .IP "1/November/2000" 4 | |
829 | .IX Item "1/November/2000" | |
830 | A few grammatical fixes and updates implemented by John Borwick. | |
831 | .IP "23/May/99" 4 | |
832 | .IX Item "23/May/99" | |
833 | Extensive updates from the net in preparation for 5.6 release. | |
834 | .IP "13/April/99" 4 | |
835 | .IX Item "13/April/99" | |
836 | More minor touch\-ups. Added new question at the end | |
837 | of perlfaq7 on variable names within variables. | |
838 | .IP "7/January/99" 4 | |
839 | .IX Item "7/January/99" | |
840 | Small touch ups here and there. Added all questions in this | |
841 | document as a sort of table of contents. | |
842 | .IP "22/June/98" 4 | |
843 | .IX Item "22/June/98" | |
844 | Significant changes throughout in preparation for the 5.005 | |
845 | release. | |
846 | .IP "24/April/97" 4 | |
847 | .IX Item "24/April/97" | |
848 | Style and whitespace changes from Chip, new question on reading one | |
849 | character at a time from a terminal using \s-1POSIX\s0 from Tom. | |
850 | .IP "23/April/97" 4 | |
851 | .IX Item "23/April/97" | |
852 | Added http://www.oasis.leo.org/perl/ to perlfaq2. Style fix to | |
853 | perlfaq3. Added floating point precision, fixed complex number | |
854 | arithmetic, cross\-references, caveat for Text::Wrap, alternative | |
855 | answer for initial capitalizing, fixed incorrect regexp, added example | |
856 | of Tie::IxHash to perlfaq4. Added example of passing and storing | |
857 | filehandles, added commify to perlfaq5. Restored variable suicide, | |
858 | and added mass commenting to perlfaq7. Added Net::Telnet, fixed | |
859 | backticks, added reader/writer pair to telnet question, added FindBin, | |
860 | grouped module questions together in perlfaq8. Expanded caveats | |
861 | for the simple \s-1URL\s0 extractor, gave \s-1LWP\s0 example, added \s-1CGI\s0 security | |
862 | question, expanded on the mail address answer in perlfaq9. | |
863 | .IP "25/March/97" 4 | |
864 | .IX Item "25/March/97" | |
865 | Added more info to the binary distribution section of perlfaq2. | |
866 | Added Net::Telnet to perlfaq6. Fixed typos in perlfaq8. Added | |
867 | mail sending example to perlfaq9. Added Merlyn's columns to | |
868 | perlfaq2. | |
869 | .IP "18/March/97" 4 | |
870 | .IX Item "18/March/97" | |
871 | Added the \s-1DATE\s0 to the \s-1NAME\s0 section, indicating which sections have | |
872 | changed. | |
873 | .Sp | |
874 | Mentioned \s-1SIGPIPE\s0 and perlipc in the forking open answer in | |
875 | perlfaq8. | |
876 | .Sp | |
877 | Fixed description of a regular expression in perlfaq4. | |
878 | .IP "17/March/97 Version" 4 | |
879 | .IX Item "17/March/97 Version" | |
880 | Various typos fixed throughout. | |
881 | .Sp | |
882 | Added new question on Perl \s-1BNF\s0 on perlfaq7. | |
883 | .IP "Initial Release: 11/March/97" 4 | |
884 | .IX Item "Initial Release: 11/March/97" | |
885 | This is the initial release of version 3 of the \s-1FAQ\s0; consequently there | |
886 | have been no changes since its initial release. |