perl - Practical Extraction and Report Language
perl[-sTuU ][-hv ] [-V[:configvar] ][-cw ] [-d[:debugger] ] [-D[number/list] ][-pna ] [-Fpattern ] [-l[octal] ] [-0[octal] ][-Idir ] [-m[-]module ] [-M[-]'module...' ][-P ][-S ][-x[dir] ][-i[extension] ][-e'command' ] [-- ] [programfile ] [argument ]...
If you're new to Perl, you should start withperlintro, which is a general intro for beginners and provides some background to help you navigate the rest of Perl's extensive documentation.
For ease of access, the Perl manual has been split up into several sections.
perlPerl overview (this section)perlintroPerl introduction for beginnersperltocPerl documentation table of contents
perlreftutPerl references short introductionperldscPerl data structures introperllolPerl data structures: arrays of arraysperlrequick Perl regular expressions quick startperlretutPerl regular expressions tutorialperlbootPerl OO tutorial for beginnersperltootPerl OO tutorial, part 1perltoocPerl OO tutorial, part 2perlbotPerl OO tricks and examplesperlstylePerl style guideperlcheatPerl cheat sheetperltrapPerl traps for the unwaryperldebtutPerl debugging tutorialperlfaqPerl frequently asked questionsperlfaq1General Questions About Perlperlfaq2Obtaining and Learning about Perlperlfaq3Programming Toolsperlfaq4Data Manipulationperlfaq5Files and Formatsperlfaq6Regexesperlfaq7Perl Language Issuesperlfaq8System Interactionperlfaq9Networking
perlsynPerl syntaxperldataPerl data structuresperlopPerl operators and precedenceperlsubPerl subroutinesperlfuncPerl built-in functionsperlopentutPerl open() tutorialperlpacktutPerl pack() and unpack() tutorialperlpodPerl plain old documentationperlpodspec Perl plain old documentation format specificationperlrunPerl execution and optionsperldiagPerl diagnostic messagesperllexwarn Perl warnings and their controlperldebugPerl debuggingperlvarPerl predefined variablesperlrePerl regular expressions, the rest of the storyperlrerefPerl regular expressions quick referenceperlrefPerl references, the rest of the storyperlformPerl formatsperlobjPerl objectsperltiePerl objects hidden behind simple variablesperldbmfilterPerl DBM filtersperlipcPerl interprocess communicationperlforkPerl fork() informationperlnumberPerl number semanticsperlthrtutPerl threads tutorialperlothrtutOld Perl threads tutorialperlportPerl portability guideperllocalePerl locale supportperluniintroPerl Unicode introductionperlunicode Perl Unicode supportperlebcdicConsiderations for running Perl on EBCDIC platformsperlsecPerl securityperlmodPerl modules: how they workperlmodlibPerl modules: how to write and useperlmodstylePerl modules: how to write modules with styleperlmodinstallPerl modules: how to install from CPANperlnewmodPerl modules: preparing a new module for distributionperlutilutilities packaged with the Perl distributionperlcompile Perl compiler suite introperlfilterPerl source filters
perlembedPerl ways to embed perl in your C or C++ applicationperldebguts Perl debugging guts and tipsperlxstutPerl XS tutorialperlxsPerl XS application programming interfaceperlclibInternal replacements for standard C library functionsperlgutsPerl internal functions for those doing extensionsperlcallPerl calling conventions from CperlapiPerl API listing (autogenerated)perlinternPerl internal functions (autogenerated)perliolC API for Perl's implementation of IO in LayersperlapioPerl internal IO abstraction interfaceperlhackPerl hackers guide
perlbookPerl book informationperltodoPerl things to doperldocLook up Perl documentation in Pod formatperlhistPerl history recordsperldeltaPerl changes since previous versionperl585deltaPerl changes in version 5.8.5perl584deltaPerl changes in version 5.8.4perl583deltaPerl changes in version 5.8.3perl582deltaPerl changes in version 5.8.2perl581deltaPerl changes in version 5.8.1perl58delta Perl changes in version 5.8.0perl573deltaPerl changes in version 5.7.3perl572deltaPerl changes in version 5.7.2perl571deltaPerl changes in version 5.7.1perl570deltaPerl changes in version 5.7.0perl561deltaPerl changes in version 5.6.1perl56delta Perl changes in version 5.6perl5005deltaPerl changes in version 5.005perl5004deltaPerl changes in version 5.004perlartisticPerl Artistic LicenseperlgplGNU General Public License
perlcnPerl for Simplified Chinese (in EUC-CN)perljpPerl for Japanese (in EUC-JP)perlkoPerl for Korean (in EUC-KR)perltwPerl for Traditional Chinese (in Big5)
perlaixPerl notes for AIXperlamigaPerl notes for AmigaOSperlapolloPerl notes for Apollo DomainOSperlbeosPerl notes for BeOSperlbs2000Perl notes for POSIX-BC BS2000perlcePerl notes for WinCEperlcygwinPerl notes for CygwinperldguxPerl notes for DG/UXperldosPerl notes for DOSperlepocPerl notes for EPOCperlfreebsd Perl notes for FreeBSDperlhpuxPerl notes for HP-UXperlhurdPerl notes for HurdperlirixPerl notes for Irixperlmachten Perl notes for Power MachTenperlmacosPerl notes for Mac OS (Classic)perlmacosxPerl notes for Mac OS XperlmintPerl notes for MiNTperlmpeixPerl notes for MPE/iXperlnetware Perl notes for NetWareperlos2Perl notes for OS/2perlos390Perl notes for OS/390perlos400Perl notes for OS/400perlplan9Perl notes for Plan 9perlqnxPerl notes for QNXperlsolaris Perl notes for Solarisperltru64Perl notes for Tru64perlutsPerl notes for UTSperlvmesaPerl notes for VM/ESAperlvmsPerl notes for VMSperlvosPerl notes for Stratus VOSperlwin32Perl notes for Windows
By default, the manpages listed above are installed in the/usr/local/man/ directory.
Extensive additional documentation for Perl modules is available. The default configuration for perl will place this additional documentation in the/usr/local/lib/perl5/man directory (or else in theman subdirectory of the Perl library directory). Some of this additional documentation is distributed standard with Perl, but you'll also find documentation for third-party modules there.
You should be able to view Perl's documentation with your man(1) program by including the proper directories in the appropriate start-up files, or in the MANPATH environment variable. To find out where the configuration has installed the manpages, type:
perl -V:man.dir
If the directories have a common stem, such as/usr/local/man/man1 and/usr/local/man/man3, you need only to add that stem (/usr/local/man) to your man(1) configuration files or your MANPATH environment variable. If they do not share a stem, you'll have to add both stems.
If that doesn't work for some reason, you can still use the suppliedperldoc script to view module information. You might also look into getting a replacement man program.
If something strange has gone wrong with your program and you're not sure where you should look for help, try the-w switch first. It will often point out exactly where the trouble is.
Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).
Perl combines (in the author's opinion, anyway) some of the best features of C,sed,awk, andsh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges ofcsh, Pascal, and even BASIC-PLUS.) Expression syntax corresponds closely to C expression syntax. Unlike most Unix utilities, Perl does not arbitrarily limit the size of your data--if you've got the memory, Perl can slurp in your whole file as a single string. Recursion is of unlimited depth. And the tables used by hashes (sometimes called "associative arrays") grow as necessary to prevent degraded performance. Perl can use sophisticated pattern matching techniques to scan large amounts of data quickly. Although optimized for scanning text, Perl can also deal with binary data, and can make dbm files look like hashes. Setuid Perl scripts are safer than C programs through a dataflow tracing mechanism that prevents many stupid security holes.
If you have a problem that would ordinarily usesed orawk orsh, but it exceeds their capabilities or must run a little faster, and you don't want to write the silly thing in C, then Perl may be for you. There are also translators to turn yoursed andawk scripts into Perl scripts.
But wait, there's more...
Begun in 1993 (seeperlhist), Perl version 5 is nearly a complete rewrite that provides the following additional benefits:
modularity and reusability using innumerable modules
Described inperlmod,perlmodlib, andperlmodinstall.
embeddable and extensible
Described inperlembed,perlxstut,perlxs,perlcall,perlguts, andxsubpp.
roll-your-own magic variables (including multiple simultaneous DBM implementations)
Described inperltie andAnyDBM_File.
subroutines can now be overridden, autoloaded, and prototyped
Described inperlsub.
arbitrarily nested data structures and anonymous functions
Described inperlreftut,perlref,perldsc, andperllol.
object-oriented programming
support for light-weight processes (threads)
Described inperlthrtut andthreads.
support for Unicode, internationalization, and localization
Described inperluniintro,perllocale andLocale::Maketext.
lexical scoping
Described inperlsub.
regular expression enhancements
enhanced debugger and interactive Perl environment, with integrated editor support
Described inperldebtut,perldebug andperldebguts.
POSIX 1003.1 compliant library
Described inPOSIX.
Okay, that'sdefinitely enough hype.
Perl is available for most operating systems, including virtually all Unix-like platforms. See"Supported Platforms" in perlport for a listing.
Seeperlrun.
Larry Wall <larry@wall.org>, with the help of oodles of other folks.
If your Perl success stories and testimonials may be of help to others who wish to advocate the use of Perl in their applications, or if you wish to simply express your gratitude to Larry and the Perl developers, please write to perl-thanks@perl.org .
"@INC"locations of perl libraries
a2pawk to perl translators2psed to perl translatorhttp://www.perl.org/ the Perl homepagehttp://www.perl.com/ Perl articles (O'Reilly Media)http://www.cpan.org/ the Comprehensive Perl Archivehttp://www.pm.org/ the Perl Mongers
Theusewarnings
pragma (and the-w switch) produces some lovely diagnostics.
Seeperldiag for explanations of all Perl's diagnostics. Theusediagnostics
pragma automatically turns Perl's normally terse warnings and errors into these longer forms.
Compilation errors will tell you the line number of the error, with an indication of the next token or token type that was to be examined. (In a script passed to Perl via-e switches, each-e is counted as one line.)
Setuid scripts have additional constraints that can produce error messages such as "Insecure dependency". Seeperlsec.
Did we mention that you should definitely consider using the-w switch?
The-w switch is not mandatory.
Perl is at the mercy of your machine's definitions of various operations such as type casting, atof(), and floating-point output with sprintf().
If your stdio requires a seek or eof between reads and writes on a particular stream, so does Perl. (This doesn't apply to sysread() and syswrite().)
While none of the built-in data types have any arbitrary size limits (apart from memory size), there are still a few arbitrary limits: a given variable name may not be longer than 251 characters. Line numbers displayed by diagnostics are internally stored as short integers, so they are limited to a maximum of 65535 (higher numbers usually being affected by wraparound).
You may mail your bug reports (be sure to include full configuration information as output by the myconfig program in the perl source tree, or byperl -V
) to perlbug@perl.org . If you've succeeded in compiling perl, theperlbug script in theutils/ subdirectory can be used to help mail in a bug report.
Perl actually stands for Pathologically Eclectic Rubbish Lister, but don't tell anyone I said that.
The Perl motto is "There's more than one way to do it." Divining how many more is left as an exercise to the reader.
The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.