perl5.14.21
The perl 5 language interpreter
Part of perl(1).
Usage
perl [-sTtuUWX]
[-hv]
[-V
[:configvar]]
[-cw]
[-d
[t]
[:debugger]]
[-D
[number/list]]
[-pna]
[-Fpattern]
[-l
[octal]]
[-0
[octal/hexadecimal]]
[-Idir]
[-m
[-]
module]
[-M
[-]
'module ...
']
[-f]
[-C
[number/list]]
[-S]
[-x
[dir]]
[-i
[extension]]
[[{-e | -E}]
'command']
[--]
[programfile]
[argument] ...
Getting help
The perldoc program gives you access to all the documentation that comes with Perl. You can get more documentation, tutorials and community support online at <http://www.perl.org/>.
If you're new to Perl, you should start by running "perldoc perlintro", which is a general intro for beginners and provides some background to help you navigate the rest of Perl's extensive documentation. Run "perldoc perldoc" to learn more things you can do with perldoc.
For ease of access, the Perl manual has been split up into several sections.
Overview
perl Perl overview (this section)perlintro Perl introduction for beginnersperltoc Perl documentation table of contents
Tutorials
perlreftut Perl references short introductionperldsc Perl data structures introperllol Perl data structures: arrays of arraysperlrequick Perl regular expressions quick startperlretut Perl regular expressions tutorialperlboot Perl OO tutorial for beginnersperltoot Perl OO tutorial, part 1perltooc Perl OO tutorial, part 2perlbot Perl OO tricks and examplesperlperf Perl Performance and Optimization Techniquesperlstyle Perl style guideperlcheat Perl cheat sheetperltrap Perl traps for the unwaryperldebtut Perl debugging tutorialperlfaq Perl frequently asked questionsperlfaq1 General Questions About Perlperlfaq2 Obtaining and Learning about Perlperlfaq3 Programming Toolsperlfaq4 Data Manipulationperlfaq5 Files and Formatsperlfaq6 Regexesperlfaq7 Perl Language Issuesperlfaq8 System Interactionperlfaq9 Networking
Reference Manual
perlsyn Perl syntaxperldata Perl data structuresperlop Perl operators and precedenceperlsub Perl subroutinesperlfunc Perl built-in functionsperlopentut Perl open() tutorialperlpacktut Perl pack() and unpack() tutorialperlpod Perl plain old documentationperlpodspec Perl plain old documentation format specificationperlpodstyle Perl POD style guideperlrun Perl execution and optionsperldiag Perl diagnostic messagesperllexwarn Perl warnings and their controlperldebug Perl debuggingperlvar Perl predefined variablesperlre Perl regular expressions, the rest of the storyperlrebackslash Perl regular expression backslash sequencesperlrecharclass Perl regular expression character classesperlreref Perl regular expressions quick referenceperlref Perl references, the rest of the storyperlform Perl formatsperlobj Perl objectsperltie Perl objects hidden behind simple variablesperldbmfilter Perl DBM filtersperlipc Perl interprocess communicationperlfork Perl fork() informationperlnumber Perl number semanticsperlthrtut Perl threads tutorialperlport Perl portability guideperllocale Perl locale supportperluniintro Perl Unicode introductionperlunicode Perl Unicode supportperlunifaq Perl Unicode FAQperluniprops Index of Unicode Version 6.0.0 properties in Perlperlunitut Perl Unicode tutorialperlebcdic Considerations for running Perl on EBCDIC platformsperlsec Perl securityperlmod Perl modules: how they workperlmodlib Perl modules: how to write and useperlmodstyle Perl modules: how to write modules with styleperlmodinstall Perl modules: how to install from CPANperlnewmod Perl modules: preparing a new module for distributionperlpragma Perl modules: writing a user pragmaperlutil utilities packaged with the Perl distributionperlcompile Perl compiler suite introperlfilter Perl source filtersperlglossary Perl Glossary
Internals and C Language Interface
perlembed Perl ways to embed perl in your C or C++ applicationperldebguts Perl debugging guts and tipsperlxstut Perl XS tutorialperlxs Perl XS application programming interfaceperlclib Internal replacements for standard C library functionsperlguts Perl internal functions for those doing extensionsperlcall Perl calling conventions from Cperlmroapi Perl method resolution plugin interfaceperlreapi Perl regular expression plugin interfaceperlreguts Perl regular expression engine internalsperlapi Perl API listing (autogenerated)perlintern Perl internal functions (autogenerated)perliol C API for Perl's implementation of IO in Layersperlapio Perl internal IO abstraction interfaceperlhack Perl hackers guideperlsource Guide to the Perl source treeperlinterp Overview of the Perl intepreter source and how it worksperlhacktut Walk through the creation of a simple C code patchperlhacktips Tips for Perl core C code hackingperlpolicy Perl development policiesperlgit Using git with the Perl repository
Miscellaneous
perlbook Perl book informationperlcommunity Perl community informationperltodo Perl things to doperldoc Look up Perl documentation in Pod formatperlhist Perl history recordsperldelta Perl changes since previous versionperl5141delta Perl changes in version 5.14.1perl5140delta Perl changes in version 5.14.0perl51311delta Perl changes in version 5.13.11perl51310delta Perl changes in version 5.13.10perl5139delta Perl changes in version 5.13.9perl5138delta Perl changes in version 5.13.8perl5137delta Perl changes in version 5.13.7perl5136delta Perl changes in version 5.13.6perl5135delta Perl changes in version 5.13.5perl5134delta Perl changes in version 5.13.4perl5133delta Perl changes in version 5.13.3perl5132delta Perl changes in version 5.13.2perl5131delta Perl changes in version 5.13.1perl5130delta Perl changes in version 5.13.0perl5123delta Perl changes in version 5.12.3perl5122delta Perl changes in version 5.12.2perl5121delta Perl changes in version 5.12.1perl5120delta Perl changes in version 5.12.0perl5115delta Perl changes in version 5.11.5perl5114delta Perl changes in version 5.11.4perl5113delta Perl changes in version 5.11.3perl5112delta Perl changes in version 5.11.2perl5111delta Perl changes in version 5.11.1perl5110delta Perl changes in version 5.11.0perl5101delta Perl changes in version 5.10.1perl5100delta Perl changes in version 5.10.0perl595delta Perl changes in version 5.9.5perl594delta Perl changes in version 5.9.4perl593delta Perl changes in version 5.9.3perl592delta Perl changes in version 5.9.2perl591delta Perl changes in version 5.9.1perl590delta Perl changes in version 5.9.0perl589delta Perl changes in version 5.8.9perl588delta Perl changes in version 5.8.8perl587delta Perl changes in version 5.8.7perl586delta Perl changes in version 5.8.6perl585delta Perl changes in version 5.8.5perl584delta Perl changes in version 5.8.4perl583delta Perl changes in version 5.8.3perl582delta Perl changes in version 5.8.2perl581delta Perl changes in version 5.8.1perl58delta Perl changes in version 5.8.0perl573delta Perl changes in version 5.7.3perl572delta Perl changes in version 5.7.2perl571delta Perl changes in version 5.7.1perl570delta Perl changes in version 5.7.0perl561delta Perl changes in version 5.6.1perl56delta Perl changes in version 5.6perl5005delta Perl changes in version 5.005perl5004delta Perl changes in version 5.004perlartistic Perl Artistic Licenseperlgpl GNU General Public License
Language-Specific
perlcn Perl for Simplified Chinese (in EUC-CN)perljp Perl for Japanese (in EUC-JP)perlko Perl for Korean (in EUC-KR)perltw Perl for Traditional Chinese (in Big5)
Platform-Specific
perlaix Perl notes for AIXperlamiga Perl notes for AmigaOSperlbeos Perl notes for BeOSperlbs2000 Perl notes for POSIX-BC BS2000perlce Perl notes for WinCEperlcygwin Perl notes for Cygwinperldgux Perl notes for DG/UXperldos Perl notes for DOSperlepoc Perl notes for EPOCperlfreebsd Perl notes for FreeBSDperlhaiku Perl notes for Haikuperlhpux Perl notes for HP-UXperlhurd Perl notes for Hurdperlirix Perl notes for Irixperllinux Perl notes for Linuxperlmacos Perl notes for Mac OS (Classic)perlmacosx Perl notes for Mac OS Xperlmpeix Perl notes for MPE/iXperlnetware Perl notes for NetWareperlopenbsd Perl notes for OpenBSDperlos2 Perl notes for OS/2perlos390 Perl notes for OS/390perlos400 Perl notes for OS/400perlplan9 Perl notes for Plan 9perlqnx Perl notes for QNXperlriscos Perl notes for RISC OSperlsolaris Perl notes for Solarisperlsymbian Perl notes for Symbianperltru64 Perl notes for Tru64perluts Perl notes for UTSperlvmesa Perl notes for VM/ESAperlvms Perl notes for VMSperlvos Perl notes for Stratus VOSperlwin32 Perl notes for Windows
On Debian systems, you need to install the perl-doc package which contains the majority of the standard Perl documentation and the perldoc program.
Extensive additional documentation for Perl modules is available, both those distributed with Perl and third-party modules which are packaged or locally installed.
You should be able to view Perl's documentation with your man(1) program or perldoc(1).
In general, 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.
Overview
Perl officially stands for Practical Extraction and Report Language, except when it doesn't.
Perl was originally a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It quickly became a good language for many system management tasks. Over the years, Perl has grown into a general-purpose programming language. It's widely used for everything from quick "one-liners" to full-scale application development.
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, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, 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 also has many excellent tools for slicing and dicing binary data.
But wait, there's more...
Begun in 1993 (see perlhist), Perl version 5 is nearly a complete rewrite that provides the following additional benefits:
- •
-
modularity and reusability using innumerable modules
Described in perlmod, perlmodlib, and perlmodinstall.
- •
-
embeddable and extensible
Described in perlembed, perlxstut, perlxs, perlcall, perlguts, and xsubpp.
- •
-
roll-your-own magic variables (including multiple simultaneous DBM implementations)
Described in perltie and AnyDBM_File.
- •
-
subroutines can now be overridden, autoloaded, and prototyped
Described in perlsub.
- •
-
arbitrarily nested data structures and anonymous functions
Described in perlreftut, perlref, perldsc, and perllol.
- •
-
object-oriented programming
Described in perlobj, perlboot, perltoot, perltooc, and perlbot.
- •
-
support for light-weight processes (threads)
Described in perlthrtut and threads.
- •
-
support for Unicode, internationalization, and localization
Described in perluniintro, perllocale and Locale::Maketext.
- •
-
lexical scoping
Described in perlsub.
- •
-
regular expression enhancements
Described in perlre, with additional examples in perlop.
- •
-
enhanced debugger and interactive Perl environment, with integrated editor support
Described in perldebtut, perldebug and perldebguts.
- •
-
POSIX 1003.1 compliant library
Described in POSIX.
Okay, that's definitely enough hype.
Environment
See perlrun.
Files
"@INC" locations of perl libraries
Diagnostics
The "use warnings" pragma (and the -w switch) produces some lovely diagnostics.
See perldiag for explanations of all Perl's diagnostics. The "use diagnostics" 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". See perlsec.
Did we mention that you should definitely consider using the -w switch?
Notes
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.