.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PERLFAQ 1" .TH PERLFAQ 1 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide" .SH "NAME" perlfaq \- frequently asked questions about Perl ($Date: 2002/03/11 21:32:23 $) .SH "DESCRIPTION" .IX Header "DESCRIPTION" The perlfaq is structured into the following documents: .Sh "perlfaq: Structural overview of the \s-1FAQ\s0." .IX Subsection "perlfaq: Structural overview of the FAQ." This document. .Sh "perlfaq1: General Questions About Perl" .IX Subsection "perlfaq1: General Questions About Perl" 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 perl4 and perl5? .IP "\(bu" 4 What is perl6? .IP "\(bu" 4 How stable is Perl? .IP "\(bu" 4 Is Perl difficult to learn? .IP "\(bu" 4 How does Perl compare with other languages like Java, Python, \s-1REXX\s0, 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 \*(L"perl\*(R" and \*(L"Perl\*(R"? .IP "\(bu" 4 Is it a Perl program or a Perl script? .IP "\(bu" 4 What is a \s-1JAPH\s0? .IP "\(bu" 4 Where can I get a list of Larry Wall witticisms? .IP "\(bu" 4 How can I convince my sysadmin/supervisor/employees to use version 5/5.6.1/Perl instead of some other language? .Sh "perlfaq2: Obtaining and Learning about Perl" .IX Subsection "perlfaq2: Obtaining and Learning about Perl" 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 on my system. How can I compile perl? .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 \s-1CPAN\s0? What does CPAN/src/... mean? .IP "\(bu" 4 Is there an \s-1ISO\s0 or \s-1ANSI\s0 certified version of Perl? .IP "\(bu" 4 Where can I get information on Perl? .IP "\(bu" 4 What are the Perl newsgroups on Usenet? Where do I post questions? .IP "\(bu" 4 Where should I post source code? .IP "\(bu" 4 Perl Books .IP "\(bu" 4 Perl in Magazines .IP "\(bu" 4 Perl on the Net: \s-1FTP\s0 and \s-1WWW\s0 Access .IP "\(bu" 4 What mailing lists are there for Perl? .IP "\(bu" 4 Archives of comp.lang.perl.misc .IP "\(bu" 4 Where can I buy a commercial version of Perl? .IP "\(bu" 4 Where do I send bug reports? .IP "\(bu" 4 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? .Sh "perlfaq3: Programming Tools" .IX Subsection "perlfaq3: Programming Tools" 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 Is there a Perl shell? .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 a ctags for Perl? .IP "\(bu" 4 Is there an \s-1IDE\s0 or Windows Perl Editor? .IP "\(bu" 4 Where can I get Perl macros for vi? .IP "\(bu" 4 Where can I get perl-mode for emacs? .IP "\(bu" 4 How can I use curses with Perl? .IP "\(bu" 4 How can I use X or Tk with Perl? .IP "\(bu" 4 How can I generate simple menus without using \s-1CGI\s0 or Tk? .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 unsafe to return a pointer to local data? .IP "\(bu" 4 How can I free an array or hash so my program shrinks? .IP "\(bu" 4 How can I make my \s-1CGI\s0 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 compile Perl into Java? .IP "\(bu" 4 How can I get \f(CW\*(C`#!perl\*(C'\fR to work on [\s-1MS\-DOS\s0,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 \s-1CGI\s0 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? [h2xs, xsubpp] .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? .Sh "perlfaq4: Data Manipulation" .IX Subsection "perlfaq4: Data Manipulation" 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 isn't my octal data interpreted correctly? .IP "\(bu" 4 Does Perl have a \fIround()\fR function? What about \fIceil()\fR and \fIfloor()\fR? Trig functions? .IP "\(bu" 4 How do I convert between numeric representations? .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 week\-of\-the\-year/day\-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 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/change the first N letters 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]? (Comma\-separated files) .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 What's wrong with always quoting \*(L"$vars\*(R"? .IP "\(bu" 4 Why don't my <<\s-1HERE\s0 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 \fIdefined()\fR return true on empty arrays and hashes? .IP "\(bu" 4 How do I process an entire hash? .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 \*(L"delete\*(R" and \*(L"undef\*(R" with hashes? .IP "\(bu" 4 Why don't my tied hashes make the defined/exists distinction? .IP "\(bu" 4 How do I reset an \fIeach()\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 \s-1DBM\s0 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 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 \s-1XS\s0 code? .Sh "perlfaq5: Files and Formats" .IX Subsection "perlfaq5: Files and Formats" I/O and the \*(L"f\*(R" 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 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? .IP "\(bu" 4 How do I count the number of lines in 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 set up a footer format to be used with \fIwrite()\fR? .IP "\(bu" 4 How can I \fIwrite()\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 \*(L"Argument list too long\*(R" when I use <*>? .IP "\(bu" 4 Is there a leak/bug in \fIglob()\fR? .IP "\(bu" 4 How can I open a file with a leading \*(L">\*(R" 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(\s-1FH\s0, \*(L">file.lock\*(R")? .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 \fIdup()\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 \*(L"C:\etemp\efoo\*(R" in \s-1DOS\s0 paths? What doesn't `C:\etemp\efoo.exe` work? .IP "\(bu" 4 Why doesn't glob(\*(L"*.*\*(R") 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? .Sh "perlfaq6: Regular Expressions" .IX Subsection "perlfaq6: Regular Expressions" Pattern matching and regular expressions. .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 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 \s-1LHS\s0 while preserving case on the \s-1RHS\s0? .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 \s-1POSIX\s0 compliant? .IP "\(bu" 4 What's wrong with using grep or map in a void context? .IP "\(bu" 4 How can I match strings with multibyte characters? .IP "\(bu" 4 How do I match a pattern that is supplied by the user? .Sh "perlfaq7: General Perl Language Issues" .IX Subsection "perlfaq7: General Perl Language Issues" 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 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 \fIlocal()\fR and \fImy()\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 \*(L"my($foo) = <\s-1FILE\s0>;\*(R" 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 \fIfoo()\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/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 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? .Sh "perlfaq8: System Interaction" .IX Subsection "perlfaq8: System Interaction" Interprocess communication (\s-1IPC\s0), control over the user-interface (keyboard, screen and pointing devices). .IP "\(bu" 4 How do I find out which operating system I'm running under? .IP "\(bu" 4 How come \fIexec()\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 \fIsleep()\fR or \fIalarm()\fR for under a second? .IP "\(bu" 4 How can I measure time under a second? .IP "\(bu" 4 How can I do an \fIatexit()\fR or \fIsetjmp()\fR/\fIlongjmp()\fR? (Exception handling) .IP "\(bu" 4 Why doesn't my sockets program work under System V (Solaris)? What does the error message \*(L"Protocol not supported\*(R" 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 \fIioctl()\fR or \fIsyscall()\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 \fIsystem()\fR? .IP "\(bu" 4 How can I capture \s-1STDERR\s0 from an external command? .IP "\(bu" 4 Why doesn't \fIopen()\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 \s-1STDIN\s0 after I gave it \s-1EOF\s0 (^D on Unix, ^Z on \s-1MS\-DOS\s0)? .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 \*(L"ps\*(R"? .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 \s-1CPU\s0 limits? .IP "\(bu" 4 How do I avoid zombies on a Unix system? .IP "\(bu" 4 How do I use an \s-1SQL\s0 database? .IP "\(bu" 4 How do I make a \fIsystem()\fR exit on control\-C? .IP "\(bu" 4 How do I open a file without blocking? .IP "\(bu" 4 How do I install a module from \s-1CPAN\s0? .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 at runtime? .IP "\(bu" 4 What is socket.ph and where do I get it? .Sh "perlfaq9: Networking" .IX Subsection "perlfaq9: Networking" Networking, the internet, and a few on the web. .IP "\(bu" 4 What is the correct form of response from a \s-1CGI\s0 script? .IP "\(bu" 4 My \s-1CGI\s0 script runs from the command line but not the browser. (500 Server Error) .IP "\(bu" 4 How can I get better error messages from a \s-1CGI\s0 program? .IP "\(bu" 4 How do I remove \s-1HTML\s0 from a string? .IP "\(bu" 4 How do I extract URLs? .IP "\(bu" 4 How do I download a file from the user's machine? How do I open a file on another machine? .IP "\(bu" 4 How do I make a pop-up menu in \s-1HTML\s0? .IP "\(bu" 4 How do I fetch an \s-1HTML\s0 file? .IP "\(bu" 4 How do I automate an \s-1HTML\s0 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 edit my .htpasswd and .htgroup files with Perl? .IP "\(bu" 4 How do I make sure users can't enter values into a form that cause my \s-1CGI\s0 script to do bad things? .IP "\(bu" 4 How do I parse a mail header? .IP "\(bu" 4 How do I decode a \s-1CGI\s0 form? .IP "\(bu" 4 How do I check a valid mail address? .IP "\(bu" 4 How do I decode a \s-1MIME/BASE64\s0 string? .IP "\(bu" 4 How do I return the user's mail address? .IP "\(bu" 4 How do I send mail? .IP "\(bu" 4 How do I use \s-1MIME\s0 to make an attachment to a mail message? .IP "\(bu" 4 How do I read mail? .IP "\(bu" 4 How do I find out my hostname/domainname/IP address? .IP "\(bu" 4 How do I fetch a news article or the active newsgroups? .IP "\(bu" 4 How do I fetch/put an \s-1FTP\s0 file? .IP "\(bu" 4 How can I do \s-1RPC\s0 in Perl? .SH "About the perlfaq documents" .IX Header "About the perlfaq documents" .Sh "Where to get the perlfaq" .IX Subsection "Where to get the perlfaq" This document is posted regularly to comp.lang.perl.announce and several other related newsgroups. It is available on many web sites: http://www.perldoc.com/ and http://perlfaq.cpan.org/ . .Sh "How to contribute to the perlfaq" .IX Subsection "How to contribute to the perlfaq" You may mail corrections, additions, and suggestions to perlfaq\-workers@perl.org . This alias should not be used to \fIask\fR FAQs. It's for fixing the current \s-1FAQ\s0. Send questions to the comp.lang.perl.misc newsgroup. .Sh "What will happen if you mail your Perl programming problems to the authors" .IX Subsection "What will happen if you mail your Perl programming problems to the authors" Your questions will probably go unread, unless they're suggestions of new questions to add to the \s-1FAQ\s0, in which case they should have gone to the perlfaq\-workers@perl.org instead. .PP You should have read section 2 of this faq. There you would have learned that comp.lang.perl.misc is the appropriate place to go for free advice. If your question is really important and you require a prompt and correct answer, you should hire a consultant. .SH "Credits" .IX Header "Credits" When I first began the Perl \s-1FAQ\s0 in the late 80s, I never realized it would have grown to over a hundred pages, nor that Perl would ever become so popular and widespread. This document could not have been written without the tremendous help provided by Larry Wall and the rest of the Perl Porters. .SH "Author and Copyright Information" .IX Header "Author and Copyright Information" Copyright (c) 1997\-2002 Tom Christiansen and Nathan Torkington. All rights reserved. .Sh "Bundled Distributions" .IX Subsection "Bundled Distributions" This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself. .PP Irrespective of its distribution, all code examples in these files are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required. .Sh "Disclaimer" .IX Subsection "Disclaimer" This information is offered in good faith and in the hope that it may be of use, but is not guaranteed to be correct, up to date, or suitable for any particular purpose whatsoever. The authors accept no liability in respect of this information or its use. .SH "Changes" .IX Header "Changes" .IP "1/November/2000" 4 .IX Item "1/November/2000" A few grammatical fixes and updates implemented by John Borwick. .IP "23/May/99" 4 .IX Item "23/May/99" Extensive updates from the net in preparation for 5.6 release. .IP "13/April/99" 4 .IX Item "13/April/99" More minor touch\-ups. Added new question at the end of perlfaq7 on variable names within variables. .IP "7/January/99" 4 .IX Item "7/January/99" Small touch ups here and there. Added all questions in this document as a sort of table of contents. .IP "22/June/98" 4 .IX Item "22/June/98" Significant changes throughout in preparation for the 5.005 release. .IP "24/April/97" 4 .IX Item "24/April/97" Style and whitespace changes from Chip, new question on reading one character at a time from a terminal using \s-1POSIX\s0 from Tom. .IP "23/April/97" 4 .IX Item "23/April/97" Added http://www.oasis.leo.org/perl/ to perlfaq2. Style fix to perlfaq3. Added floating point precision, fixed complex number arithmetic, cross\-references, caveat for Text::Wrap, alternative answer for initial capitalizing, fixed incorrect regexp, added example of Tie::IxHash to perlfaq4. Added example of passing and storing filehandles, added commify to perlfaq5. Restored variable suicide, and added mass commenting to perlfaq7. Added Net::Telnet, fixed backticks, added reader/writer pair to telnet question, added FindBin, grouped module questions together in perlfaq8. Expanded caveats for the simple \s-1URL\s0 extractor, gave \s-1LWP\s0 example, added \s-1CGI\s0 security question, expanded on the mail address answer in perlfaq9. .IP "25/March/97" 4 .IX Item "25/March/97" Added more info to the binary distribution section of perlfaq2. Added Net::Telnet to perlfaq6. Fixed typos in perlfaq8. Added mail sending example to perlfaq9. Added Merlyn's columns to perlfaq2. .IP "18/March/97" 4 .IX Item "18/March/97" Added the \s-1DATE\s0 to the \s-1NAME\s0 section, indicating which sections have changed. .Sp Mentioned \s-1SIGPIPE\s0 and perlipc in the forking open answer in perlfaq8. .Sp Fixed description of a regular expression in perlfaq4. .IP "17/March/97 Version" 4 .IX Item "17/March/97 Version" Various typos fixed throughout. .Sp Added new question on Perl \s-1BNF\s0 on perlfaq7. .IP "Initial Release: 11/March/97" 4 .IX Item "Initial Release: 11/March/97" This is the initial release of version 3 of the \s-1FAQ\s0; consequently there have been no changes since its initial release.