Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix perl command

Quick links

About perl
Syntax
Examples
Where to obtain Perl
Related commands
Linux / Unix main page

About perl

Perl is a programming 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).

Syntax

perl [-s] [-T] [-u] [-U] [-h] [-v] [-V[:configvar] ] [-c] [-w] [-d[:debugger] ] [ -D[number/list] ] [-p] [-n] [-a] [ -F pattern ] [ -l[octal] ] [-0[octal] ] [ -Idir ] [ -m[-]module ] [ -M[-]'module...' ]  -P] [-S] [-x[dir] ] [ -i[extension] ]  -e 'command'] [ -- ] [programfile] [argument]

-sEnables rudimentary option parsing for options on the command line after the script name but before any file name arguments (or before a --).
-TForces "taint" checks to be turned on so you can test them.
-u
-UAllows perl to do unsafe operations.
-h
-vPrints the version and patch level configuration of your perl executable.
-V[:conigvar]Prints summary of the major perl configuration values and the current value of @INC.
-cChecks the syntax of the script and then exits without executing it.
-wPrints warnings about variable names that are mentioned only once, and scalar variables that are used before being set.
-dRuns the script under the perl debugger
-D

Sets debugging flags. To turn on debugging flags, you can either specify a number which is the total of the numeric values of the desired flags (for example, -D14 turns on the Trace Execution, Label Stack Processing, and Stack Snapshots flags) or a list of the letters associated with those flags (for example, -Dtls is the same as -D14). Another nice value is -Dx, which lists your compiled syntax tree. And -Dr displays compiled regular expressions. The available flags are:

1pTokenizing and parsing
2sStack snapshots
4lLable stack processing
8tTrace execution
16oOperator node construction
32cString/numeric conversions
64pPrint processor command for -P
128mMemory allocation
256fFormat processing
512rRegular expression parsing
1024xSyntax tree dump
2048uTainting checks
4096LMemory leaks (not supported with later versions)
8192HHash dump -- usurps values ()
16384XScratchpad allocation
32768DCleaning up

-passumes the following loop around your script.

while (<>) {
# your script goes here
} continue {
print or die "-p destination: $!\n";
}

-nAssumes the following loop around your script.

while (<>) {
# your script goes here
 }

-aTurns on autosplit mode when used with a -n or -p.
-F patternSpecifies a pattern expression to split on
-l octalEnables automatic line-ending processing.
-0 octalSpecifies the input record separator ($/) as an octal number. If there are no digits, the null character is the separator. Other options may precede or follow the digits.
-I dirPrepends directory to the search path for modules (@INC)
-m moduleExecutes use module (); before executing the script.
-M 'module'executes use module ; before executing the script.
-PRuns your script through the preprocessor script cppstdin before compilation by perl.
-SUses the PATH environment variable to search for the script (unless the name of the script starts with a slash).
-x dirTells perl that the script is embedded in a message.
-i extensionspecifies that files processed by the <> construct are to be edited in-place.
-e commandSpecifies a line of script.
--
programfileName of the perl program
agument

Examples

perl myscript.cgi -d - Would run a debug though the CGI / Perl Script myscript.cgi and if any errors are reported stop and report them else wise run through the complete script.

Where to obtain perl

Perl is available in a wide range of operating systems, below is a listing of operating systems which currently support Perl or have planned versions of Perl being released for them. Versions, additional information and downloads can be found at: http://www.perl.com/CPAN/ports/index.html

AIXLinuxSCO ODT/OSRA/UXMachTen
SolarisBeOSMPE/iXSunOSBSD/OS
NetBSDSVR4DG/UXNextSTEPTru64
DomainOSOpenBSDUltrixDOS DJGPPOpenSTEP
UNICOSDYNIX/ptxOS/2VMSFreeBSD
OS390VOSHP-UXPowerMAXWindows 3.1
HurdQNXWindows 95Windows 98Windows NT
3b1FPSPlan 9AmigaOSGENIX
PowerUXConvexOSGreenhillsRISC/osCX/UX
ISCStellarDC/OSxMachTen 68kSVR2
DDE SMESMiNTTI1500DOS EMXMPC
TitanOSDynixNEWS-OSUNICOS/mkEP/IX
OpusUnisys DynixEsixUnixwareBS2000
NetwareRhapsodyVM/ESA

Related commands

a2p
s2p

 

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope