|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259
|
|
Chapter 19:
|
|
|
|
|
Operators
|
|
"That's not a regular rule; you invented it just now."
"It's the oldest rule in the book," said the King.
Then it ought to be number One," said Alice.
|
|
- Lewis Carroll, Alice's Adventures in Wonderland
|
|
This chapter provides a brief reference guide to the Perl (symbolic) opera-
tors and escape sequences. Perl has several dozen operators, far exceeding
the counts of most modern programming languages. Actually, if you count
the "named operators", such as sleep, there are over a hundred! For rea-
sons of laziness,1however, we have chosen to treat Perl's named operators
as if they were functions; you can find them in the next chapter (along with
the control flow modifiers).
|
|
Nonetheless, the combinatorial complexity produced by Perl's wealth of
even symbolic operators can be very confusing. In particular, it can make it
difficult to read code that was written by other (ahem), less-restrained
programmers. Fear not; if the Perl interpreter can figure this out, so can you!
|
|
Precedence And Associativity
|
|
Perl's operator precedence and associativity rules allow the interpreter to
determine the order in which expressions should be evaluated. The rules
actually work quite well; in most cases, if a programmer naively writes an
|
|
|
|
1One of the cardinal virtues in Perl!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expression, Perl will do what he expects. On the other hand, it's the little
exceptions that make life so very interesting.
|
|
Consequently, you would be well-advised to add a few sets of parentheses
when writing complex expressions. That way, neither you nor the poor guy
who has to maintain your code will have to remember all of Perl's twenty-
four (24!) levels of precedence and (corresponding) associativity rules.
|
|
Even so, you will occasionally encounter a piece of Perl code that doesn't use
parentheses, so you will want to have a quick reference on Perl's operator
precedence and associativity rules. Let's start with the official table,
adapted slightly from the Perl manual pages:
|
|
Operator(s)
|
Associativity
|
|
Terms, list operators (leftward)left
->left
++ --none
**right
! ~ \ and unary +and -right
=~ !~left
* / % xleft
+ - .left
<< >>left
Named unary operatorsnone
< > <= >= lt gt le genone
== != <=> eq ne cmpnone
&left
| ^left
&&left
.. ...none
?:right
= += -= *= etc.right
, =>left
List operators (rightward)none
notright
andleft
or xorleft
|
|
In general, if you find yourself confronted by some overly "cute" code (e.g.,
code that relies on obscure precedence or associativity interactions), your
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
best strategy is to add parentheses until the order of operations is self-
evident. Be careful to follow the precedence and associativity rules,
however, lest you break the code you are trying to understand!
|
|
Precedence
|
|
Operators that are higher in the table have higher precedence; that is,
they are interpreted before those with lower precedence. As you might
expect, the multiply (*) and divide (/) operators have higher precedence
than the add (+) and substract (-) operators. So, the expression:
|
|
$a * $x + $b
|
|
is interpreted as meaning:
|
|
($a * $x) + $b
|
|
After that, however, things get a bit more challenging. How, for instance,
should the following expression be parsed?
|
|
$i ++ / 27 >= $j -- << 3
|
|
Well, looking at the table, we see that the increment (++) and decrement
(--) operators have the highest precedence of any operators used in the
expression. So, we can rewrite the expression as:
|
|
($i++) / 27 >= ($j--) << 3
|
|
The division (/) operator comes next in the table, giving us:
|
|
(($i++) / 27) >= ($j--) << 3
|
|
Finally, we get to the left-shift (<<) operator:
|
|
(($i++) / 27) >= (($j--) << 3)
|
|
Although the intent of the expression may still be unclear (and should be
clarified by a comment!), the specific order of evaluation is not. By "steam-
cleaning" imported code as you work on it, you can make life easier for your-
self and successive maintainers.
|
|
Associativity
|
|
Associativity only comes into play when operators of equal precedence are
combined in an expression. The Associativity column in the table indicates
whether given operators are left, right, or non-associative. Again, by judi-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cious use of parentheses, you can avoid worrying about associativity at all.
But, if you get stuck with some ugly code, here are some hints at parsing it:
|
|
$a - $b + $c - $d
|
|
Because the add (+) and subtract (-) operators are left associative, the
expression groups from left to right:
|
|
(($a - $b) + $c) - $d
|
|
Right associativity works in an analogous manner; this expression:
|
|
$a ** $b ** $c ** $d
|
|
evaulates as:
|
|
$a ** ($b ** ($c ** $d))
|
|
Some operators are not associative at all. Thus, when these operators are
used, no particular grouping order is defined. Fortunately, as in this string
concatenation example, the grouping order generally doesn't matter:
|
|
$a . $b . $c
|
|
Arithmetic Operators
|
|
The arithmetic operators are used when working with numeric expressions.
These operators all operate in floating point mode, with one exception.
Modulus operations are done in integer mode.
|
|
+ addition $a + 1
- subtraction $a - 2
* multiplication 2 * 2
/ division 355 / 113
= assignment $pi = 3.14159
** exponentiation 10 ** 3
% modulus (integer remainder) $y % 5
|
|
String Operators
|
|
x
.
|
repeat by
concatenate with
|
'o' x 5
'butter' . 'fly'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assignment Operators
|
|
By mixing the various arithmetic operators with the assignment operator,
we get a collection of "shortcut" assignment operators.
|
|
=
+=
-=
*=
/=
%=
**=
++
--
|
"assignment"
"increment by"
"decrement by"
"multiply by"
"divide by"
"modulo by"
"raise to the power"
"autoincrement"
"autodecrement"
|
$pi = 3.14159
$x += 2# $x = $x + 2
$y -= 2# $y = $y - 2
$w *= 7# $w = $w * 7
$v /= 2# $v = $v / 2
$u %= 5# $u = $u % 5
$t **= 7# $t = $t ** 7
$s++# $s = $s + 1
$r--# $r = $r - 1
|
|
Comparison Operators
|
|
There are two types of comparison operators. Numeric comparison operators
work only on numbers and look like mathematical symbols.
|
|
<
>
<=
>=
!=
==
<=>
|
less than
greater than
less than or equal to
greater than or equal to
not equal to
equal to (equality)
signed comparison
|
2 < 3
4 > 3
$i <= 0
$x >= 10
5 != 7
2 == 2
|
|
String comparison operators work only on strings; their names are alpha-
betic strings as well (e.g., cmp). When comparing strings, remember that
Perl is case sensitive.
|
|
lt
gt
le
ge
ne
eq
cmp
|
less than
greater than
less than or equal to
greater than or equal to
not equal to
equal to
signed comparison
|
'three' lt 'two'
'three' gt 'four'
'a' le 'a'
'b' ge 'a'
'ONE' ne 'one'
'one' eq 'one'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logical Operators
|
|
Boolean, or logical, operators evaluate from left to right, determining the
truth of a statement in as few operations as possible. Consider this
|
|
if (($a == 1) && ($b < 2))
|
|
If $ais not 1, there is no point in evaluating the remainder of the
expression, so Perl doesn't. These operators return the last value evaluated
(not simply 1 or 0). The alphabetic versions (e.g., and, or) have lower
precedence than their symbolic counterparts and are more mnemonic. They
were created to be used in statements such as
|
|
open(IN, $file) or die;
|
|
The negation operators (!and not) return 1 if their operand is false;
otherwise they return the null string. The xor, exclusive OR, operator has
no direct counterpart. For an xoroperation to evaluate as true, exactly one
of the two operands evaluated must be true. Consequently, both operands
will always be evaluated.
|
|
!
&&
||
not
and
or
xor
|
"logical NOT"
"logical AND"
"logical OR"
"logical NOT"
"logical AND"
"logical OR"
"logical XOR"
|
negate the truth of the expression
both operands must be true
one or both operands may be true
negate the truth of the expression
both operands must be true
one or both operands may be true
exactly one operand must be true
|
|
Bitwise logical operators perform their operations on the bits of the string
(or number). These operators work on either string or numeric expressions,
but work differently on each. If both operands are strings (or numbers), they
are treated as strings (or numbers). However, if one operand is a string and
the other is a number, the string will be converted to a number.
|
|
~
&
|
^
|
"bitwise NOT"
"bitwise AND"
"bitwise OR"
"bitwise XOR"
|
~1
5 & 3
5 | 3
5 ^ 3
|
# 4294967294
# 1
# 7
# 6
|
|
Bitwise negation produces the 1's complement of the input, evaluated as a
32-bit wide integer. That is, it turns all of the 1's into 0's and vice versa.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The first example above may thus be explained as follows:
|
|
Thirty-two bit binary value
00000000 00000000 00000000 00000001
11111111 11111111 11111111 11111110
|
Decimal value
1
4294967294
|
|
Bit-Shift Operators
|
|
The bit-shift operators return the value of the left-hand argument shifted
(left or right) by the number of bits specified by the right-hand operator.
|
|
<<
>>
|
left shift
right shift
|
3 << 1
6 >> 1
|
# 12
# 3
|
|
Binding (Matching) Operators
|
|
The binding operators binda scalar expression to a pattern match, a
substitution, or a translation. The return value of !~is the logical negation
of =~, i.e., the pattern didn't match (!~is unlikely to be meaningful in a
substitution or translation).
|
|
=~
!~
|
matches
does not match
|
$str =~ m/pat*/
$str !~ m/pat*/
|
|
Reference / Dereference Operators
|
|
The backslash, \, serves as a reference operator. This use of \should not be
confused with the \used in creating escape sequences (described later in
this chapter). As a reference operator, \creates a reference to the argument
that follows. If used on a list of items, it will return a list of references to
each element of the input list.
|
|
The arrow operator, ->, is the dereference operator; if the argument on the
right hand side is an array or hash subscript, the argument on the left hand
side is a reference to an array or hash. Otherwise, the right hand argument
must be a method name (or scalar variable containing a method name); the
left hand argument must either be an object or a class (package) name.
|
|
\
->
|
reference
dereference (arrow)
|
\*STDOUT
$array->[1]
|
|
The *in the first example, \*STDOUT, is used to prefix a typeglob; type-
globs are useful for passing or storing filehandles.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Range Operators
|
|
In list context, the range operator returns a list of all values between the
left and right arguments, inclusive. For example, the following code
fragment sets a loop from 1 to 10 by 1.
|
|
foreach $ndx (1..10) { print("$ndx\n"); }
|
|
In scalar context, the range operator returns true or false, flip-flopping
based on the values of its operands. The return value remains false as long
as the left argument remains false (the right argument is not evaluated). If
the left argument becomes true, ..returns true and then remains true (not
evaluating the left argument) until the right argument becomes true. After
that, it becomes false again.2
|
|
The ..operator can test the right argument and become false again
immediately. If this is not the behavior you want, use the ...operator
instead; it does not test the right hand argument until the next evaluation.
Otherwise, the two are identical.
|
|
..
...
|
range (flip-flop)
range (flip-flop)
|
1..10
/^Date/ ... /^$/
|
|
Comma Operator
|
|
In scalar context, the comma operator, ,, evaluates its left hand argument,
discarding the value, then evaluates the right hand argument and returns
that value. You might wonder how this could be useful.
|
|
The following example (without annotation) can be found in Programming
Perl, chapter 2. It parses switches(i.e., input arguments which begin with a
dash, -).3
|
|
while ($_ = $ARGV[0], /^-/) {
shift;
last if /^--$/;
|
|
|
|
2Think of it as waiting to cross a street. Look to the left until it is safe to cross, then
look to the right until it is safe to cross, then look back to the left.
3Note that while it is trivial to pass arguments of this type to the MPW perl tool, it is
considerably more difficult when using the MacPerl application. However, the point of
this example is to discuss the comma operator, not parsing arguments, per se.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that this code takes advantage of various defaults; the following is
equivalent but more verbose
|
|
while ($_ = $ARGV[0], $_ =~ /^-/) {
shift(@ARGV);
last if ($_ =~ /^--$/);
|
|
But how do we explain the multiple arguments to while(and the comma)?
Recall the explanation of the comma operator above. It first evaluates the
left hand argument, the expression $_ = $ARGV[0], which it discards
(ignores). However, the expression is evaluated. The comma then causes
evaluation of the right hand argument (the pattern match) and returns the
result of this evaluation. Because the left side was evaluated, $_can be
used in the right hand expression. Entry into the loop depends upon
whether the (recently set) value of $_matches /^-/.
|
|
In list context, the comma operator is only a simple list argument separator;
it doesn't throw anything away! The somewhat fancier =>is a synonym for
the comma; it looks prettier when separating key / value pairs in hash
definitions. It also happens, conveniently, to force the argument on its left
to be interpreted as a string.
|
|
,
=>
|
"comma"
"argument pairs"
|
$x = ($a = 2, 3); @a = (1, 2);
%h = (a => 'red');
|
|
Conditional Operator
|
|
The ?: operator implements a very terse if-then-else style conditional,
without taking up a lot of space; it can readily be embedded within other
expressions. If the argument to the left of the ?evaluates to true, then the
expression in the middle is evaluated and returned; otherwise, the right
hand expression (to the right of the :) is evaluated and returned.
|
|
?:
|
conditional
|
# $a = ($b > 3) ? 1 : 0;
|
|
File Test Operators
|
|
The file test operators are unary operators. Each takes one argument (a
filename or a filehandle) and tests an attribute of the associated file. Each
returns 1 if the test holds true, 0 if false.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Many of these operators are meaningless (and therefore not implemented)
on Mac OS, or have somewhat different meanings in MacPerl. In the
descriptions below, the following typography conventions apply:
|
|
-
Boldindicates that the operator works unchanged in MacPerl.
|
|
-
Bold-Italicindicates that the operator is not available or is
significantly different in MacPerl; we may have included information
on workarounds, etc.
|
|
-
Italicindicates that the operator is not available in MacPerl.
|
|
File Mode (Permission)
-g-o
-k-O
File Type
-b-c
-B-d
Existence and Size
-e-s
Age
-A-C
|
|
|
|
-r
-R
|
-u
|
-w
-W
|
-x
-X
|
|
|
-f
-l
|
-p
-S
|
-t
-T
|
|
|
-z
|
|
|
-M
|
|
File Test Synopses
|
|
-? FILEHANDLE
-? EXPR
-?
All file test operators share the same syntax. We will not repeat it
below. If no argument is given, tests $_(unless specified).
|
|
-A
This test is treated by MacPerl as a synonym for the -Mtest. Under
Unix, it returns the time since the file was last accessed.
|
|
-b
This test is not supported by MacPerl (returns a null string). Under Unix,
it returns true if the argument is a "block special" file (buffered device).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-B
File is a binary file. This test may mis-classify Macintosh text files
containing many 8-bit ("option") characters. This is the opposite of -T.
|
|
-c
This test is not supported by MacPerl (returns a null string). Under Unix,
it returns true if the argument is a "character special" file (raw / un-
buffered device).
|
|
-C
Age of file in days since the file was created (as shown by Get Info),
where 0is the time the script started running. A file that was created
after the current script started would have a negative age. Under Unix,
the "creation date" refers to the most recent change to the inode.
|
|
-d
File is a directory (folder).
|
|
-e
File exists.
|
|
-f
File is a regular file.
|
|
-g
This test is not supported by MacPerl (returns a null string). Under Unix,
it returns a true value if the argument has the "setgid" bit set.
|
|
-k
This test is not supported by MacPerl (returns a null string). Under Unix,
it returns a true value if the argument has the "sticky" bit set.
|
|
-l
File is a symbolic link (alias).
|
|
-M
Age of file in days since last modification (as shown by Get Info), where
0is the time the script started running. A file that was modified after
the current script started would have a negative age.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-o
This test is not supported by MacPerl (returns 1). Under Unix, it returns
a true value if the argument is owned by the user's effective uid.
|
|
-O
This test is not supported by MacPerl (returns 1). Under Unix, it returns
a true value if the argument is owned by the user's real uid.
|
|
-p
This test is not supported by MacPerl (returns 1). Under Unix, it returns
a true value if the argument is a named pipe (FIFO).
|
|
-r, -R
File is readable. Under Unix, this applies to the effective (-r) or the
real (-R) uid/gid. Under Mac OS, these tests have only a very limited
meaning ; -Ris indistinguishable from -r.
|
|
-s
File exists and has non-zero size. Returns size of the file in bytes (as
shown by Get Info).
|
|
-S
File is a socket.
|
|
-t
Filehandle is open to a terminal window. If no argument is specified,
tests STDIN.
|
|
-T
File is a text file. This test may mis-classify Mac text files containing
many 8-bit ("option") characters. This is the opposite of -B.
|
|
-u
This test is not supported by MacPerl (returns 1). Under Unix, it returns
a true value if the argument has the "setuid" bit set.
|
|
-w, -W
File is writeable. Under Unix, this applies to the effective (-w) or the
real (-W) uid/gid. Under Mac OS, these tests have only a very limited
meaning ; -Wis indistinguishable from -w.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-x, -X
File is executable. Under Unix, this applies to the effective (-x) or the
real (-X) uid/gid. Under Mac OS, these tests have only a very limited
meaning ; -Xis indistinguishable from -x.
|
|
-z
File exists and has zero size.
|
|
Quoting
|
|
Perl provides the customary quoting characters which we have discussed
previously:
|
|
'...'
"..."
`...`
(...)
${...}
<<EOF
|
single quotes; literal, with no interpolation
double quotes; literal, with interpolation of $, @, and \
backquotes; command evaluation4
word list (comma separated)
a single identifier within the braces is treated as if in '...'
start of a here document; interpolated unless 'EOF'
|
|
You may also choose instead to use the "generic" versions:
|
|
q/.../
qq/.../
qx/.../
qw/.../
|
literal; equivalent to '...'for each member
literal; equivalent to "..." for each member
command evaluation; equivalent to `...` (caveats included :-)
word list; equivalent to (...), without the commas!
|
|
Everything between the delimiting /characters is considered to be quoted,
as if each element had been quoted in the "conventional" manner. However,
you are able to enclose the "conventional" quote marks within the quoted
material without resorting to using \to escape their special meaning.
|
|
$message = q/Don't type that!/;
$error = qq/The file "myfile" could not be found/;
@days = qw/Monday Wednesday Friday/;
|
|
Note that, as with pattern matching, the /is only a typical delimiter; any
non-alphanumeric (non-whitespace) character may be used as the
delimiter. In particular, if you choose a bracketing character as the starting
delimiter (e.g. (,[,{, or <), the ending delimiter will be the matching
|
|
|
|
4With ToolServer; otherwise, only a few specific commands are implemented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bracket. Embedding of delimiters is possible; embedded delimiters must
match in pairs.
|
|
$date_str = q{Date: 02/28/98};
@days = qw(Monday Wednesday Friday);
|
|
The matching, m//, substitution, s///, and translation, tr///, operators
can be considered as quoting methods. However, because these have rather
"function-like" capabilities, we have chosen to postpone their discussion to
the next chapter, Reserved Words.
|
|
Escape Sequences
|
|
The escape sequences are not, technically speaking, operators. They do not
act upon their arguments (in fact, they have no arguments). However, they
look as much like "line noise" as everything we have discussed so far in
this chapter, and we could think of no better place to list them. So here
they are. Each of these can be used to match a particular character, or
character class, in a regular expression pattern. The first group can also be
used in printstatements.
|
|
\
\a
\f
\r
\n
\t
\b
|
"escape" character
alarm (bell)
formfeed
return5
newline6
horizontal tab
backspace7
|
|
\0n
\d
\D
|
match an octal number n8
match any digit [0-9]
match any nondigit
|
|
|
|
5On Unix systems (\015);generates a linefeed under MacPerl (\012).
6Generates a linefeed under Unix (\012); generates a carriage return (\015) under
MacPerl.
7Note that \bhas different meanings depending upon where it is used. In a character
class or double-quoted string it represents a backspace. In parts ofa regular
expression, however, it represents a word boundary.
8A backslashed two- or three-digit octal number matches the character with that octal
(ASCII) value. For example, \015 matches the carriage returncharacter, ^M.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\w
\s
\b
|
match any "word" character (letter, digit, or underscore)
match any whitespace character (e.g., tab, space, newline)
match at a word boundary
|
|
Regular Expressions
|
|
The Regular Expression operators are used in defining patterns. Do not con-
fuse them with the other Perl operators which use the same characters!
|
|
[]describe a character class9
()parenthesize for grouping
{n,m}must match no fewer than nbut no more than mtimes
{n,}must match no fewer than n times
{n}must match exactly ntimes
*match 0 or more times; equivalent to {0,}
+must match 1 or more times; equivalent to {1,}
?must match exactly 0 or 1 times; equivalent to {0,1}
^anchor a pattern to the beginning of the line
$anchor a pattern to the end of the line
.match any (single) character10
|provide a choice of alternative matches
|
|
Switches
|
|
Perl switches(also called optionsor flags) may be specified on the command
line or as part of the #!line that begins a script. While Perl recognizes
nearly two dozen switches, not all of these are supported or have the same
meaning under MacPerl as under Perl for Unix. Because of the way in which
the #!line is emulated in MacPerl, many switches are supported from the
command line only (MPW perl tool) and cannot be used in the #!line.
|
|
Several switches take (possibly optional) arguments. Optional arguments
are shown within brackets, []. Descriptive argument strings are given in
italics. Be sure to use the name of a real module, command, etc., in place of
the generic argument string!
|
|
|
|
9A character classis a set of characters, where the pattern may match any of the set.
For example, the regular expression class [0123456789]describes the set of digits
from 0through 9, inclusive. For series classes, a dash, -, may be used to represent
missing but assumed members (e.g., [0-9]also represents the same set of digits).
10Except \nunless you use the /smodifier on your pattern.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-0[octal]
Specify the input record separator (in octal). Default is null, 0. Use 00
to specify a blank line as the record separator (i.e., #!perl -000).
Equivalent to setting the $/variable.
|
|
-a
Autosplit mode with -nor -p(implicitly splits $_into @F, splitting on
spaces.). See also -F.
|
|
-c
Check syntax only (but run BEGINand ENDblocks). Equivalent to
selecting Syntax Checkfrom the MacPerl application Scriptsmenu.
|
|
-d[:module]
Run script under the Perl debugger, optionally specifying a debugging
module. Equivalent to selecting Perl Debuggerin the MacPerl applica-
tion Scriptsmenu.
|
|
-D[number/list]
Set debugging flags (argument is a bit mask or flags). This only works if
you have recompiled MacPerl with the -DDEBUGGING flag set.
Unrelated to the Perl debugger.
|
|
-e 'commands'
Specify the complete script (usually one line) as the argument. MPW
perl tool only; unsupported in #!perlline. If more than one Perl state-
ment is included, escape any embedded returns with ð (option-d).
|
|
-F/pattern/
Specify the patternfor autosplitting (-a). The //'s are optional.
|
|
-h
Print help information (all possible switches and brief explanations).
|
|
-i[extension]
Edit files processed by <>in place(i.e., the output will be placed back
into the input file).11If extensionis supplied, a backup copy of the
|
|
|
|
11In actuality, the input file is renamed and a new output file is created with the name
of the original input file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
original file will be made, with extensionadded to the filename.
Otherwise, the original input file is replaced.
|
|
-Idirectory
Specify a library directoryto add to @INC, telling Perl where to
search for modules (may be used more than once).
|
|
-l[octal]
Enable automatic line ending processing (printstatements no longer
require \n), optionally specifying the output record separator in octal.
Default is the current value of the input record separator (i.e., newline
unless modified). Turns on automatic chomping if used with -nor -p.
|
|
-Mmodule
-mmodule
Execute usemodule... before executing script.
|
|
-M-module
-m-module
Execute nomodule... before executing script.
|
|
-n
Assume a while (<>) { ... }style loop around script, auto-
matically iterating over all input files. Use of -poverrides -n.
|
|
-p
Assume a loop like -n |