PERLFAQ(7) Perl Programmers Reference Guide PERLFAQ(7) NAME perlfaq - Perl (2003/01/31 17:37:17) DESCRIPTION perlfaq Where to get the perlfaq comp.lang.perl.misc http://www.perldoc.com/ http://faq.perl.org/ http://2Ti.com/cgi- bin/2T/perl/ ftp://www.math.ncu.edu.tw/pub/staff/chenym/FAQ/Perl/ How to contribute to the perlfaq perlfaq perlfaq-workers@perl.org . FAQ comp.lang.perl.misc http://cvs.perl.org/cvsweb/perlfaq/ ()CVS FAQ What will happen if you mail your Perl programming problems to the authors FAQ perlfaq-workers@perl.com FAQ comp.lang.perl.misc Credits perlfaq Tom Christiansen Tom Nathan Torkington perlfaq-workers (perlfaq-workers@perl.org) Author and Copyright Information Copyright (c) 1997-2003 Tom Christiansen, Nathan Torkington, and other contributors noted in the answers. All rights reserved. Bundled Distributions This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself. 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. 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. Table of Contents perlfaq - perlfaq1 - Perl perlfaq2 - Perl perlfaq3 - perlfaq4 - perlfaq5 - perlfaq6 - perlfaq7 - perlfaq8 - perlfaq9 - The Questions perlfaq1: Perl Perl o Perl? o Perl o Perl o perl4 perl5 o perl6 ? o Perl o Perl o Perl Java, Python, REXX, Scheme, Tcl o Perl o Perl o perlPerl o Perl program script o JAPH o Larry Wall (witticisms) o 5/5.8.3 Perl perlfaq2: Perl Perl o Perl o Perl o C perl o Perl o perl gdbm/dynamic loading/malloc/linking/... o Perl CPAN CPAN/src/... o ISO ANSI Perl o Perl o USENET Perl o o Perl o Perl o Perl FTP WWW o Perl o comp.lang.perl.misc o Perl o bugs o perl.com? Perl Mongers? pm.org? perl.org? cpan.org? perlfaq3: o ()? o Perl? o Perl shell? o o Perl ? o (profile) perl ? o Perl (cross-reference)? o Perl (pretty-printer)? o Perl ctags ? o IDE Perl o vi Perl o emacs perl? o Perl curses? o X Tk Perl? o CGI Tk ? o Perl? o Perl o ? o ? o CGI (script)? o Perl? o Perl byte code C? o Perl Java? o "#!perl" [MS-DOS,NT,...] ? o ? o perl DOS/Mac/VMS? o Perl CGI Web? o Perl o Perl C [h2xs, xsubpp] o perlembed,perlguts C perl o o MakeMaker? perlfaq4: o Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)? o Why isn't my octal data interpreted correctly? o Does Perl have a round() function? What about ceil() and floor()? Trig functions? o How do I convert between numeric representations? o Why doesn't & work the way I want it to? o How do I multiply matrices? o How do I perform an operation on a series of integers? o How can I output Roman numerals? o Why aren't my random numbers random? o How do I get a random number between X and Y? o How do I find the day or week of the year? o How do I find the current century or millennium? o How can I compare two dates and find the difference? o How can I take a string and turn it into epoch seconds? o How can I find the Julian Day? o How do I find yesterday's date? o Does Perl have a Year 2000 problem? Is Perl Y2K compliant? o How do I validate input? o How do I unescape a string? o How do I remove consecutive pairs of characters? o How do I expand function calls in a string? o How do I find matching/nesting anything? o How do I reverse a string? o How do I expand tabs in a string? o How do I reformat a paragraph? o How can I access or change N characters of a string? o How do I change the Nth occurrence of something? o How can I count the number of occurrences of a substring within a string? o How do I capitalize all the words on one line? o How can I split a [character] delimited string except when inside [character]? o How do I strip blank space from the beginning/end of a string? o How do I pad a string with blanks or pad a number with zeroes? o How do I extract selected columns from a string? o How do I find the soundex value of a string? o How can I expand variables in text strings? o What's wrong with always quoting "$vars"? o Why don't my < I/O and the "f" issues: filehandles, flushing, formats, and footers. o How do I flush/unbuffer an output filehandle? Why must I do this? o 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? o How do I count the number of lines in a file? o How can I use Perl's "-i" option from within a program? o How do I make a temporary file name? o How can I manipulate fixed-record-length files? o 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? o How can I use a filehandle indirectly? o How can I set up a footer format to be used with write()? o How can I write() into a string? o How can I output my numbers with commas added? o How can I translate tildes (~) in a filename? o How come when I open a file read-write it wipes it out? o Why do I sometimes get an "Argument list too long" when I use <*>? o Is there a leak/bug in glob()? o How can I open a file with a leading ">" or trailing blanks? o How can I reliably rename a file? o How can I lock a file? o Why can't I just open(FH, ">file.lock")? o I still don't get locking. I just want to increment the number in the file. How can I do this? o 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? o How do I randomly update a binary file? o How do I get a file's timestamp in perl? o How do I set a file's timestamp in perl? o How do I print to more than one file at once? o How can I read in an entire file all at once? o How can I read in a file by paragraphs? o How can I read a single character from a file? From the keyboard? o How can I tell whether there's a character waiting on a filehandle? o How do I do a "tail -f" in perl? o How do I dup() a filehandle in Perl? o How do I close a file descriptor by number? o Why can't I use "C:\temp\foo" in DOS paths? What doesn't `C:\temp\foo.exe` work? o Why doesn't glob("*.*") get all the files? o Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? o How do I select a random line from a file? o Why do I get weird spaces when I print an array of lines? perlfaq6: o ? o ? o ? o $/? o LHS RHS? o "\w" (accented)? o locale "/[a-zA-Z]/" ? o (quote) ? o "/o" ? o C? o Perl? o ?? o ? o ? o ? o ? o "\b" ? o $&, $`, $'? o "\G" ? o Perl DFA NFA? POSIX ? o grep map? o ? o perlfaq7: Perl o Perl BNF/yacc/RE o $@%* o / o o o (extension) o Perl C o / o o o o o o /{ Function, FileHandle, Array, Hash, Method, Regex}? o o local() my() ? o o o "my($foo) = ;" o o &foo foo() ? o o o o o perl o o o "bad interpreter" ? perlfaq8: (IPC), () o o exec() ? o o o o o o o o o o o / o Unix shadow o o sleep() alarm() ? o o atexit() setjmp()/longjmp() o sockets System V (Solaris) o Perl C o ioctl() syscall() o setuid perl o (pipe) o system() o STDERR o open() o o shell o EOFUnix ^DMS-DOS ^Z STDIN o shell perl o perl telnet ftp o Perl Expect o perl "ps" o perl script {} o o fork o o o CPU ? o Unix o SQL ? o system() control-C ? o o CPAN ? o require use o / o / o include o socket.ph perlfaq9: web o CGI o CGI (500 Server Error) o CGI o HTML o URL? o o HTML ? o HTML ? o HTML ? o web %-encoding? o o o Perl .htpasswd .htgroup ? o CGI o o CGI o o MIME/BASE64 ? o o o MIME o o //IP o o / FTP ? o RPC ? bbbush man man https://github.com/man-pages-zh/manpages- zh perl v5.8.3 2003-11-25 PERLFAQ(7)