PERL(1) Perl Programmers Reference Guide PERL(1)
NAME
perl Practical Extraction and Report Language
SYNOPSIS
perl [ sTtuUWX ] [ hv ] [ V[:congvar ] ]
[ cw ] [ d [t][:debugger] ] [ D[number/list] ]
[ pna ] [ F pattern ] [ l [octal] ] [ 0 [octal/hexadecimal] ]
[ I dir ] [ m[ ]module ] [ M[ ]'module...'] [ f ] [ C [ number/list] ] [ P ]
[ S ] [ x [dir] ] [ i [extension] ]
[ e'command'] [ ] [ programle ] [ v5.10.0 2007-12-18 1
PERL(1) Perl Programmers Reference Guide PERL(1)
perlsyn Perl syntax
perldata Perl data structures
perlop Perl operators and precedence
perlsub Perl subroutines
perlfunc Perl built
2 2007-12-18 perl v5.10.0
PERL(1) Perl Programmers Reference Guide PERL(1)reapi Perl regular expression plugin interface
perlreguts Perl regular expression engine internals
perlapi Perl API listing (autogenerated)
perlintern Perl internal functions (autogenerated)
perliol C API for Perls implementation of IO in Layers
perlapio Perl internal IO abstraction interface
perlhack Perl hackers guide
Miscellaneous
perlbook Perl book information
perlcommunity Perl community information
perltodo Perl things to do
perldoc Look up Perl documentation in Pod format
perlhist Perl history records
perldelta Perl changes since previous version
perl v5.10.0 2007-12-18 3
PERL(1) Perl Programmers Reference Guide PERL(1)
Language-Specic
perlcn Perl for Simplified Chinese (in EUCCN)
perljp Perl for Japanese (in EUCJP)
perlko Perl for Korean (in EUCKR)
perltw Perl for Traditional Chinese (in Big5)
Platform-Specic
perlaix Perl notes for AIX
perlamiga Perl notes for AmigaOS
perlapollo Perl notes for Apollo DomainOS
perlbeos Perl notes for BeOS
perlbs2000 Perl notes for POSIXBChpux Perl notes for HPUX
By default, the manpages listed above are installed in the/usr/local/man/directory.
Extensive additional documentation for Perl modules is available. The default conguration for perl will
place this additional documentation in the/usr/local/lib/perl5/man directory (or else in the man
subdirectory of the Perl library directory).Some of this additional documentation is distributed standard
with Perl, but you'll also nd 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 les, or in the MANPATH environment variable. To nd out where the
conguration 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) conguration les 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 supplied perldoc script to view module
4 2007-12-18 perl v5.10.0
PERL(1) Perl Programmers Reference Guide PERL(1)
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 rst.It will often point out exactly where the trouble is.
DESCRIPTION
Perl is a language optimized for scanning arbitrary text les, extracting information from those text les,
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, efcient, complete) rather than beautiful (tin y,
elegant, minimal).
Perl closely to C expression
syntax. Unlike most Unix utilities, Perl does not arbitrarily limit the size of your data i f you've got the
memory,Perl can slurp in your whole le les look lik e
hashes. Setuid Perl scripts are safer than C programs through a datao w benets:implementations).
l exical 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.
perl v5.10.0 2007-12-18 5
PERL(1) Perl Programmers Reference Guide PERL(1)
POSIX 1003.1 compliant library
Described in POSIX.
Okay,that's denitely enough hype.
AV AILABILITY
Perl is available for most operating systems, including virtually all Unix-like platforms. See``Supported
Platforms''in perlport for a listing.
ENVIRONMENT
See perlrun.thanks@perl.or g.
FILES
"@INC" locations of perl libraries
SEE ALSO
a2p awk to perl translator
s2p sed to perl translator the Perl homepage Perl articles (ORe denitely consider using the w switch?
BUGS
The w switch is not mandatory.
Perl is at the mercy of your machine's denitions of v arious operations such as type casting,atof(),and
oating giv en conguration information as output by the mycong.'' D ivining 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
6 2007-12-18 perl v5.10.0
PERL(1) Perl Programmers Reference Guide PERL(1)
why.
perl v5.10.0 2007-12-18 7
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
NAME
perlsyn Perl syntax
DESCRIPTION gure
ev en English. Other languages have borrowed syntax from Perl, particularly its regular expression
extensions. So if you have programmed in another language you will see familiar pieces in Perl.They
often work the same, but see perltrap for information about how they differ.
Declarations
The only things you need to declare in Perl are report formats and subroutines (and sometimes not even
subroutines). A variable holds the undened v alue (undef) until it has been assigned a dened v alue, notied of an uninitialized v alue whenever you treat
undef as a string or a number.Well, usually.Boolean contexts, such as:
my $a;
if ($a) {}
are exempt from warnings (because they care about truth rather than denedness).Operators such as ++,
,+=,=,and.=,that operate on undened left values such as:
my $a;
$a++;
are also always exempt from such warnings.
A declaration can be put anywhere a statement can, but has no effect on the execution of the primary
sequence of statements d eclarations all take effect at compile time.Typically all the declarations are put
at the beginning or the end of the script.However, if you're using lexically-scoped private variables created
with my(),you'll have to make sure your format or subroutine denition dening it by saying sub name,thus:
sub myname;
$me = myname $0 or die "cant.
8 2007-12-18 perl v5.10.0
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
Te xt from a"#"character until the end of the line is a comment, and is ignored.Exceptions include"#"
inside a string or regular expression.
Simple Statements
The only kind of simple statement is an expression evaluated for its side effects. Every simple statement
must be terminated with a semicolon, unless it is the nal statement in a block, in which case the semicolon
is optional.(A semicolon is still encouraged if the block takes up more than one line, because you may
ev entually add another line.) Note that there are some operators like eval {} and do {} that look like
compound statements, but aren't (they're just TERMs in an expression), and thus need an explicit
termination if used as the last item in a statement..
Statement Modiers
Any simple statement may optionally be followed by a SINGLE modier,just before the terminating
semicolon (or block ending).The possible modiers are:
if EXPR
unless EXPR
while EXPR
until EXPR
foreach LIST
The EXPR following the modier is referred to as the ``condition''. Its truth or falsehood determines how
the modier will beha ve. modier is an iterator: it e xecutes modiers ha ve the usual "while loop" semantics (conditional evaluated rst),
except when applied to a doBLOCK (or to the deprecated doSUB modiers don't take loop labels.Sorry.You can always put another block inside of it
(for next) or around it (for last) to do that sort of thing.For next,just double the braces:
perl v5.10.0 2007-12-18 9
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
do {{
next if $x == $y;
#do something here
}} until $x++ > $z;
For last,you have to be more elaborate:
LOOP: {
do {
last if $x = $y**2;
#do something here
} while $x++ <= $z;
}
NOTE:The behaviour of a my statement modied with a statement modier conditional or loop construct
(e.g.my $x if ...) is undened.The value of the my variable may be undef,any previously
assigned value, or possibly anything else.Don't rely on it.Future versions of perl might do something
different from the version of perl you try it out on.Here be dragons.
Compound Statements
In Perl, a sequence of statements that denes a scope is called a block.Sometimes a block is delimited by
the le containing it (in the case of a required le, ow: dened in terms of BLOCKs, not statements.This means that the
curly brackets are requiredno dangling statements allo wed. If you want to write conditionals without
curly brackets there are several other ways to do it.The following all do the same thing:
if (!open(FOO)) { die "Cant open $FOO: $!"; }
die "Cant open $FOO: $!" unless open(FOO);
open(FOO) or die "Cant open $FOO: $!";#FOO or bust!
open(FOO) ? hi mom : die "Cant identier
followed by a colon.The LABEL identies the loop for the loop control statements next,last,and
redo.If the LABEL is omitted, the loop control statement refers to the innermost enclosing loop.This
may include dynamically looking back your call-stack at run time to nd the LABEL.Such desperate
behavior triggers a warning if you use the use warnings pragma or the w ag.
If there is a continue BLOCK,it is always executed just before the conditional is about to be evaluated
again. Thus it can be used to increment a loop variable, even when the loop has been continued via the
next statement.
10 2007-12-18 perl v5.10.0
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
Loop Control le lik e rst iteration.
The loop control statements don't work in an if or unless,since they aren't loops. You can double the
braces to make them such, though.
perl v5.10.0 2007-12-18 11
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
if (/pattern/) {{
last if /fred/;
next if /barney/; # same effect as "last", but doesnt).
For Loops
Perl's Cstyle-le on an interacti ve le
12 2007-12-18 perl v5.10.0
PERLSYN(1) Perl Programmers Reference Guide PERLSYN; # cant ofcial switch statement.
perl v5.10.0 2007-12-18 13
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
Switch statements exible and powerful. For example: complicated_check($foo) is true;
}
default {
die q(I dont:
o a subroutine or method call
o a regular expression match, i.e./REGEX/or $foo =~ /REGEX/,or a neg ated regular expression
match $foo !~ /REGEX/.
14 2007-12-18 perl v5.10.0
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
o a comparison such as $_ < 10 or $x eq "abc"(or of course $_ ~~ $c)
o defined(...),exists(...),or eof(...)
o A negated expression!(...) or not (...),or a logical exclusive-or (...) xor (...).
then rst''f or more information on smart matching.
Breaking out
You can use the break keyword to break out of the enclosing given block. Every when block is
implicitly ended with a break.
Fall-through
You can use the continue keyword to fall through from one case to the next:
given($foo) {
when (/x/) { say $foo contains an x; continue }
when (/y/) { say $foo contains a y }
default { say $foo contains neither an x nor a y }
}
Switching in a loop rst match.
This doesn't work if you explicitly specify a loop variable, as in for $item (@array).You have to
use the default variable $_.(You can use for my $_ (@array).)
Smart matching in detail
The behaviour of a smart match depends on what type of thing its arguments are. It is always commutative,
i.e.$a ~~ $b behaves the same as $b ~~ $a.The behaviour is determined by the following table: the
rst ro w
perl v5.10.0 2007-12-18 15
PERLSYN(1) Perl Programmers Reference Guide PERLSYN.
Custom matching via overloading
You can change the way that an object is matched by overloading the ~~ operator.This trumps the usual
smart match semantics.See overload.
Differences from Perl 6 specication,,hav e a boolean type.)
Goto
Although not for the faint of heart, Perl does support a goto statement. There are three forms:
gotoLABEL,gotoEXPR, and goto&NAME. A loop's LABEL is not actually a valid target for a
goto;it's just the name of the loop.
The gotoLABEL form nds
16 2007-12-18 perl v5.10.0
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
such as last or die.The author of Perl has never felt the need to use this form of goto (in Perl, that
is C is another matter).
The gotoEXPR rst place (e xcept that any
modications to @_ in the current subroutine are propagated to the other subroutine.) After the goto,not
ev en caller() will be able to tell that this routine was called rst.
In almost all cases like this, it's usually a far,far better idea to use the structured control o w mechanisms
of next!)
Perl can process line directives, much like the C preprocessor.Using this, one can control Perl's idea of
lenames and line numbers in error or w arning messages (especially for strings that are processed with
eval()). The syntax for this mechanism is the same as for most C preprocessors: it matches the regular
expression
perl v5.10.0 2007-12-18 17
PERLSYN(1) Perl Programmers Reference Guide PERLSYN(1)
#example: # line 42 "new_filename.plx"
/^\# \s*
line \s+ (\d+)\s*
(?:\s("?)([^"]+)\2)? \s*
$/x
with $1 being the line number for the next line, and $3 being the optional lename (specied with or
without quotes).
There is a fairly obvious gotcha included with the line directive:Debuggers and prolers will only sho w the
last source line to appear at a particular line number in a given le..
18 2007-12-18 perl v5.10.0
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
NAME
perldata Perl data types
DESCRIPTION
Variable rst character of the name tells
you to what sort of data structure it refers.The rest of the name tells you the particular value to which it
refers. Usually this name is a single identier,that is, a string beginning with a letter or underscore, and
containing letters, underscores, and digits.In some cases, it may be a chain of identiers, separated by::
(or by the slightly archaic ); all but the last are interpreted as names of packages, to locate the namespace
in which to look up the nal identier (see ``Packages''i n perlmod for details).It's possible to substitute
for a simple identier,an expression that produces a reference to the value at runtime.This is described in
more detail below and in perlref.
Perl also has its own built-in variables whose names don't follow these rules.They hav '$', e ven when referring to a scalar that is part of an array or a hash.
The '$' symbol works semantically lik e the English word ``the''in t hat lik '*', b ut
you don't really care about that yet (if ever:).
Every variable type has its own namespace, as do several non-variable identiers.This means that you can,
without fear of conict, use the same name for a scalar variable, an array,or a hash or,for that matter,for
a le lehandles, ho wever, which
don't hav e an initial special character.You can't hav e a lehandle named ``log'', for instance.Hint: you
could say open(LOG,logfile) rather than open(log,logfile).Using uppercase
lehandles also impro ves readability and protects you from conict with future reserv ed words. Case is
signicant``FOO'',``Foo'', and ``foo''a re all different names.Names that start with a letter or
underscore may also contain digits and underscores.
It is possible to replace such an alphanumeric name with an expression that returns a reference to the
appropriate type.For a description of this, see perlref.
perl v5.10.0 2007-12-18 19
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
Names that start with a digit may contain only more digits.Names that do not start with a letter,
underscore, digit or a caret (i.e.a control character) are limited to one character,e.g.,$% or $$.(Most of
these one character names have a predened signicance to Perl.For instance,$$ is the current process
id.)
``sh''a nd ` nd the integer value of that line and
return that.If, on the other hand, you say
sort( <STDIN> )
then the sort operation provides list context for <>, which will proceed to read every line available up to the
end of le,-dened subroutines may choose to care whether the.
Scalar values
All data in Perl is a scalar,an array of scalars, or a hash of scalars.A scalar may contain one single value in
any of three different a vors:''s trings), a dened one
and an undened one.The dened version is just a string of length zero, such as"".The undened
version is the value that indicates that there is no real value for something, such as when there was an error,
or at end of le, or when you refer to an uninitialized v ariable or element of an array or hash.Although in
20 2007-12-18 perl v5.10.0
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
early versions of Perl, an undened scalar could become dened when rst used in a place expecting a
dened value, this no longer happens except for rare cases of auto vivication as explained in perlref.You
can use the dened() operator to determine whether a scalar value is dened (this has no meaning on arrays
or hashes), and the undef() operator to produce an undened value.
To nd doesnt nd the length of array @days by evaluating $#days,
as in csh.Howev er,.)
You can also gain some minuscule measure of efcienc y $[: les that don't set the value of $[ no longer need to worry
about whether another le changed its v alue.  nd, a fatal error will result, since this bucket usage
information is currently not available for tied hashes.
You can preallocate space for a hash by assigning to the keys() function. This rounds up the allocated
buckets to the next power of two:
perl v5.10.0 2007-12-18 21
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
keys(%users) = 1000;#allocate 1024 buckets
Scalar value constructors
Numeric literals are specied in an y of the following oating point or integer formats:
12345
12345.67
.23Estyle backslash rules apply for making
characters such as newline, tab, etc., as well as some more exotic forms.See ``Quote and Quote-like
Operators''in perlop for a list.
Hexadecimal, octal, or binary,representations in string literals (e.g. '0xf f') are not automatically converted
to their integer representation.The hex() and oct() functions make these conversions for you.See ``hex''i oating $whos variable. The
last two would be the $0 and the $s variables in the (presumably) non-existent package who.
In fact, an identier within such curlies is forced to be a string, as is an y simple identier}++.
Version Strings
Note:Version Strings (vstrings) ha ve been deprecated.They will be removed in some future release after
Perl 5.8.1.The marginal benets of vstrings were greatly outweighed by the potential for Surprise and
22 2007-12-18 perl v5.10.0
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
Confusion.
A literal of the form v1.20.300.4000 is parsed as a string composed of characters with the specied
ordinals. This form, known as vstrings, provides an alternati vestrings for IPv4 addresses is not portable unless you also use the inet_aton()/inet_ntoa() routines of the
Socket package.
Note that since Perl 5.8.1 the single-number vstrings (lik e v65) are not vstrings before the => operator
(which is usually used to separate a hash key from a hash value), instead they are interpreted as literal
strings ('v65'). They were vstrings from Perl 5.6.0 to Perl 5.8.0, but that caused more confusion and
breakage than good.Multi-number vstrings lik e v65.66 and 65.66.67 continue to be vstrings
always.
Special Literals
The special literals _ _FILE_ _,_ _LINE_ _,and _ _PACKAGE_ _ represent the current lename, line
number,and package name at that point in your program.They may be used only as separate tokens; they
will not be interpolated into strings.If there is no current package (due to an empty package;directive),
_ _PA CKAGE_ _ is the undened value.
The two control characters ^D and ^Z, and the tokens __END_ _ and _ _DAT A_ _ may be used to indicate
the logical end of the script before the actual end of le.An y following text is ignored.
Te xt after _ _DAT A_ _ but may be read via the lehandle PACKNAME::DATA,where PACKNAME is the
package that was current when the _ _DAT A_ _ token was encountered.The lehandle is left open pointing
to the contents after _ _DAT A_ _.It is the program's responsibility to close DATA when it is done
reading from it.For compatibility with older scripts written before _ _DAT A_ _ was introduced, _ _END_ _
behaves like _ _DAT A_ _ in the top level script (but not in les loaded with require or do) and leaves the
remaining contents of the le accessible via main::DATA.
See SelfLoader for more description of _ _DAT A_ _,and an example of its use.Note that you cannot read
from the DATA lehandle in a BEGIN block: the BEGIN block is executed as soon as it is seen (during
compilation), at which point the corresponding _ _DAT A_ _ (or _ _END_ _) token has not yet been seen.
Barewords
A word that has no other interpretation in the grammar will be treated as if it were a quoted string.These
are known as ``barewords''. As with lehandles and labels, a bare word that consists entirely of lowercase
letters risks conict Joining Delimiter
Arrays and slices are interpolated into double-quoted strings by joining the elements with the delimiter
specied in the $"variable ($LIST_SEPARATOR if ``use English;''is s pecied), space by def ault. The
following are equivalent:
$temp = join($", @ARGV);
system "echo $temp";
system "echo @ARGV";
perl v5.10.0 2007-12-18 23
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1) value constructors
List values are denoted by separating individual values by commas (and enclosing the list in parentheses
where precedence requires it):
(LIST)
In a context not requiring a list value, the value of what appears to be a list literal is simply the value of the
nal t rst of which ends
with that optional comma.1,,3 is (1,),(3) is 1,3 (And similarly for 1,,,3 is (1,),(,),3 is
1,3 and so on.) Not that we'd advise you to use this obfuscation.
24 2007-12-18 perl v5.10.0
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A nished, nal element of a list assignment may be an array or a hash:
($a, $b, @rest) = split;
my($a, $b, %rest) = @_;
You can actually put an array or hash anywhere in the list, but the rst one in the list will soak up all the
values, and anything after it will become undened atten out into k ey/value pairs.That's why it's good to use references sometimes.
It is often more readable to use the => operator between key/value pairs.The => operator is mostly just a
perl v5.10.0 2007-12-18 25
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
more visually distinctive synonym for a comma, but it also arranges for its left-hand operand to be
interpreted as a string i f it's a bareword that would be a legal simple identier ( => doesn't quote
compound identiers,.
Subscripts
An array is subscripted by specifying a dollar sign ($), then the name of the array (without the leading @),
then the subscript inside square brackets. For example:
@myarray = (5, 50, 500, 5000);
print "Element Number 2wins First Name is ", $scientists{"Darwin"}, "\n";
Slices.
26 2007-12-18 perl v5.10.0
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A(1)
( ev en le is exhausted, the
result is 0, not 2.
If you're confused about why you use an '@' there on a hash slice instead of a '%', think of it lik e).
Typeglobs and Filehandles
Perl uses an internal type called a typeglob to hold an entire symbol table entry.The type prex:
perl v5.10.0 2007-12-18 27
PERLDAT A(1) Perl Programmers Reference Guide PERLDAT A lehandles into a function or to create ne w lehandles. If you need to
use a typeglob to save away a lehandle, do it this way:
$fh = *STDOUT;
or perhaps as a real reference, like this:
$fh = \*STDOUT;
See perlsub for examples of using these as indirect lehandles in functions.
Typeglobs are also a way to create a local le lehandle
manipulations, although they're still needed to pass brand new le lehandles ( open(),opendir(),pipe(),socketpair(),sysopen(),
socket(),and accept()) automatically create an anonymous lehandle if the handle passed to them is an
uninitialized scalar variable. This allows the constructs such as open(my $fh, ...) and
open(local $fh,...) to be used to create lehandles that will con veniently be closed automatically
when the scope ends, provided there are no other references to them. This largely eliminates the need for
typeglobs when opening lehandles that must be passed around, as in the following example:
sub myopen {
open my $fh, "@_"
or die "Cant lehandles is with the Symbol module or with the IO::Handle module
and its ilk.These modules have the advantage of not hiding different types of the same name during the
local().See the bottom of ``open()'' i.
28 2007-12-18 perl v5.10.0
PERLOP(1) Perl Programmers Reference Guide PERLOP(1)
NAME is evaluated rst yielding 2 + 20 == 22 and not 6 *
5 == 30.
Operator associativity denes what happens if a sequence of the same operators is used one after another:
whether the evaluator will evaluate the left operations rst or the right.For example, in 8 4 2,
subtraction is left associative so Perl evaluates the expression left to right.8 4 is evaluated rst making
the expression 4 2 == 2 and not 8 2 == 6..
Terms and List Operators (Leftward)
perl v5.10.0 2007-12-18 29
PERLOP(1) Perl Programmers Reference Guide PERLOP(1)
with rst");
See ``Named Unary Operators''f or more discussion of this.
Also parsed as terms are the do {} and eval {} constructs, as well as subroutine and method calls, and
the anonymous constructors [] and {}.
See also ``Quote and Quote-like Operators''t ow ard the end of this section, as well as ``I/O Operators''.
The Arrow Operator
">"is an inx.
Auto-increment and Auto-decrement
``++''a nd ``''work as in C.That is, if placed before a variable, they increment or decrement the variable
by one before returning the value, and if placed after,increment or decrement after returning the value.
$i = 0;$j = 0;
print $i++;#prints 0
print ++$j;#prints 1
Note that just as in C, Perl doesn't dene when the variable is incremented or decremented. You just know
it will be done sometime before or after the value is returned. This also means that modifying a variable
twice in the same statement will lead to undened behaviour.Avoid statements like:
$i = $i ++;
print ++ $i + $i ++;
Perl will not guarantee what the result of the above statements/^[azAZ]*[09]*\z/,the increment is done as a string, preserving each
30 2007-12-18 perl v5.10.0
PERLOP(1) Perl Programmers Reference Guide PERLOP(1)
character within its range, with carry:
print ++($foo = 99);#prints 100
print ++($foo = a0);#prints a1
print ++($foo = Az);#prints Ba
print ++($foo = zz);#prints aaa
undef is always treated as numeric, and in particular is changed to 0 before incrementing (so that a