perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / perl.man.1
index 3a4db8b..69f373f 100644 (file)
@@ -1,13 +1,28 @@
 .rn '' }`
-''' $Header: perl.man.1,v 2.0.1.1 88/06/28 16:28:09 root Exp $
+''' $Header: perl_man.1,v 3.0.1.5 90/03/27 16:14:37 lwall Locked $
 ''' 
 ''' $Log:      perl.man.1,v $
-''' Revision 2.0.1.1  88/06/28  16:28:09  root
-''' patch1: fixed some quotes
-''' patch1: clarified syntax of LIST
+''' Revision 3.0.1.5  90/03/27  16:14:37  lwall
+''' patch16: .. now works using magical string increment
 ''' 
-''' Revision 2.0  88/06/05  00:09:23  root
-''' Baseline version 2.0.
+''' Revision 3.0.1.4  90/03/12  16:44:33  lwall
+''' patch13: (LIST,) now legal
+''' patch13: improved LIST documentation
+''' patch13: example of if-elsif switch was wrong  
+''' 
+''' Revision 3.0.1.3  90/02/28  17:54:32  lwall
+''' patch9: @array in scalar context now returns length of array
+''' patch9: in manual, example of open and ?: was backwards
+''' 
+''' Revision 3.0.1.2  89/11/17  15:30:03  lwall
+''' patch5: fixed some manual typos and indent problems
+''' 
+''' Revision 3.0.1.1  89/11/11  04:41:22  lwall
+''' patch2: explained about sh and ${1+"$@"}
+''' patch2: documented that space must separate word and '' string
+''' 
+''' Revision 3.0  89/10/18  15:21:29  lwall
+''' 3.0 baseline
 ''' 
 ''' 
 .de Sh
 .ds L' `
 .ds R' '
 'br\}
-.TH PERL 1 LOCAL
+.TH PERL 1 "\*(RP"
+.UC
 .SH NAME
-perl - Practical Extraction and Report Language
+perl \- Practical Extraction and Report Language
 .SH SYNOPSIS
-.B perl [options] filename args
+.B perl
+[options] filename args
 .SH DESCRIPTION
 .I Perl
-is a interpreted language optimized for scanning arbitrary text files,
+is an interpreted 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.
@@ -69,13 +86,39 @@ so people familiar with those languages should have little difficulty with it.
 (Language historians will also note some vestiges of \fIcsh\fR, Pascal, and
 even BASIC-PLUS.)
 Expression syntax corresponds quite closely to C expression syntax.
+Unlike most Unix utilities,
+.I perl
+does not arbitrarily limit the size of your data\*(--if you've got
+the memory,
+.I perl
+can slurp in your whole file as a single string.
+Recursion is of unlimited depth.
+And the hash tables used by associative arrays grow as necessary to prevent
+degraded performance.
+.I Perl
+uses sophisticated pattern matching techniques to scan large amounts of
+data very quickly.
+Although optimized for scanning text,
+.I perl
+can also deal with binary data, and can make dbm files look like associative
+arrays (where dbm is available).
+Setuid
+.I perl
+scripts are safer than C programs
+through a dataflow tracing mechanism which prevents many stupid security holes.
 If you have a problem that would ordinarily use \fIsed\fR
 or \fIawk\fR or \fIsh\fR, but it
 exceeds their capabilities or must run a little faster,
 and you don't want to write the silly thing in C, then
 .I perl
 may be for you.
-There are also translators to turn your sed and awk scripts into perl scripts.
+There are also translators to turn your
+.I sed
+and
+.I awk
+scripts into
+.I perl
+scripts.
 OK, enough hype.
 .PP
 Upon startup,
@@ -89,9 +132,11 @@ switches on the command line.
 Contained in the file specified by the first filename on the command line.
 (Note that systems supporting the #! notation invoke interpreters this way.)
 .Ip 3. 4 2
-Passed in implicity via standard input.
+Passed in implicitly via standard input.
 This only works if there are no filename arguments\*(--to pass
-arguments to a stdin script you must explicitly specify a - for the script name.
+arguments to a
+.I stdin
+script you must explicitly specify a \- for the script name.
 .PP
 After locating your script,
 .I perl
@@ -107,38 +152,50 @@ only allows one argument.  Example:
 .nf
 
 .ne 2
-       #!/usr/bin/perl -spi.bak        # same as -s -p -i.bak
+       #!/usr/bin/perl \-spi.bak       # same as \-s \-p \-i.bak
        .\|.\|.
 
 .fi
 Options include:
 .TP 5
 .B \-a
-turns on autosplit mode when used with a \-n or \-p.
+turns on autosplit mode when used with a
+.B \-n
+or
+.BR \-p .
 An implicit split command to the @F array
 is done as the first thing inside the implicit while loop produced by
-the \-n or \-p.
+the
+.B \-n
+or
+.BR \-p .
 .nf
 
-       perl -ane 'print pop(@F),"\en";'
+       perl \-ane \'print pop(@F), "\en";\'
 
 is equivalent to
 
        while (<>) {
-               @F = split(' ');
-               print pop(@F),"\en";
+               @F = split(\' \');
+               print pop(@F), "\en";
        }
 
 .fi
 .TP 5
-.B \-D<number>
+.BI \-d
+runs the script under the perl debugger.
+See the section on Debugging.
+.TP 5
+.BI \-D number
 sets debugging flags.
 To watch how it executes your script, use
-.B \-D14.
+.BR \-D14 .
 (This only works if debugging is compiled into your
 .IR perl .)
+Another nice value is \-D1024, which lists your compiled syntax tree.
+And \-D512 displays compiled regular expressions.
 .TP 5
-.B \-e commandline
+.BI \-e " commandline"
 may be used to enter one line of script.
 Multiple
 .B \-e
@@ -149,7 +206,7 @@ is given,
 .I perl
 will not look for a script filename in the argument list.
 .TP 5
-.B \-i<extension>
+.BI \-i extension
 specifies that files processed by the <> construct are to be edited
 in-place.
 It does this by renaming the input file, opening the output file by the
@@ -157,12 +214,12 @@ same name, and selecting that output file as the default for print statements.
 The extension, if supplied, is added to the name of the
 old file to make a backup copy.
 If no extension is supplied, no backup is made.
-Saying \*(L"perl -p -i.bak -e "s/foo/bar/;" .\|.\|. \*(R" is the same as using
+Saying \*(L"perl \-p \-i.bak \-e "s/foo/bar/;" .\|.\|. \*(R" is the same as using
 the script:
 .nf
 
 .ne 2
-       #!/usr/bin/perl -pi.bak
+       #!/usr/bin/perl \-pi.bak
        s/foo/bar/;
 
 which is equivalent to
@@ -171,8 +228,8 @@ which is equivalent to
        #!/usr/bin/perl
        while (<>) {
                if ($ARGV ne $oldargv) {
-                       rename($ARGV,$ARGV . '.bak');
-                       open(ARGVOUT,">$ARGV");
+                       rename($ARGV, $ARGV . \'.bak\');
+                       open(ARGVOUT, ">$ARGV");
                        select(ARGVOUT);
                        $oldargv = $ARGV;
                }
@@ -181,18 +238,22 @@ which is equivalent to
        continue {
            print;      # this prints to original filename
        }
-       select(stdout);
+       select(STDOUT);
 
 .fi
-except that the \-i form doesn't need to compare $ARGV to $oldargv to know when
+except that the
+.B \-i
+form doesn't need to compare $ARGV to $oldargv to know when
 the filename has changed.
 It does, however, use ARGVOUT for the selected filehandle.
-Note that stdout is restored as the default output filehandle after the loop.
+Note that
+.I STDOUT
+is restored as the default output filehandle after the loop.
 .Sp
 You can use eof to locate the end of each input file, in case you want
 to append to each file, or reset line numbering (see example under eof).
 .TP 5
-.B \-I<directory>
+.BI \-I directory
 may be used in conjunction with
 .B \-P
 to tell the C preprocessor where to look for include files.
@@ -202,7 +263,7 @@ By default /usr/include and /usr/lib/perl are searched.
 causes
 .I perl
 to assume the following loop around your script, which makes it iterate
-over filename arguments somewhat like \*(L"sed -n\*(R" or \fIawk\fR:
+over filename arguments somewhat like \*(L"sed \-n\*(R" or \fIawk\fR:
 .nf
 
 .ne 3
@@ -218,10 +279,10 @@ to have lines printed.
 Here is an efficient way to delete all files older than a week:
 .nf
 
-       find . -mtime +7 -print | perl -ne 'chop;unlink;'
+       find . \-mtime +7 \-print | perl \-ne \'chop;unlink;\'
 
 .fi
-This is faster than using the -exec switch find because you don't have to
+This is faster than using the \-exec switch of find because you don't have to
 start a process on every filename found.
 .TP 5
 .B \-p
@@ -252,76 +313,132 @@ switch.
 .B \-P
 causes your script to be run through the C preprocessor before
 compilation by
-.I perl.
+.IR perl .
 (Since both comments and cpp directives begin with the # character,
 you should avoid starting comments with any words recognized
 by the C preprocessor such as \*(L"if\*(R", \*(L"else\*(R" or \*(L"define\*(R".)
 .TP 5
 .B \-s
 enables some rudimentary switch parsing for switches on the command line
-after the script name but before any filename arguments (or before a --).
+after the script name but before any filename arguments (or before a \-\|\-).
 Any switch found there is removed from @ARGV and sets the corresponding variable in the
 .I perl
 script.
 The following script prints \*(L"true\*(R" if and only if the script is
-invoked with a -xyz switch.
+invoked with a \-xyz switch.
 .nf
 
 .ne 2
-       #!/usr/bin/perl -s
+       #!/usr/bin/perl \-s
        if ($xyz) { print "true\en"; }
 
 .fi
 .TP 5
 .B \-S
-makes perl use the PATH environment variable to search for the script
+makes
+.I perl
+use the PATH environment variable to search for the script
 (unless the name of the script starts with a slash).
 Typically this is used to emulate #! startup on machines that don't
 support #!, in the following manner:
 .nf
 
        #!/usr/bin/perl
-       eval "exec /usr/bin/perl -S $0 $*"
+       eval "exec /usr/bin/perl \-S $0 $*"
                if $running_under_some_shell;
 
 .fi
 The system ignores the first line and feeds the script to /bin/sh,
-which proceeds to try to execute the perl script as a shell script.
+which proceeds to try to execute the
+.I perl
+script as a shell script.
 The shell executes the second line as a normal shell command, and thus
-starts up the perl interpreter.
+starts up the
+.I perl
+interpreter.
 On some systems $0 doesn't always contain the full pathname,
-so the -S tells perl to search for the script if necessary.
-After perl locates the script, it parses the lines and ignores them because
+so the
+.B \-S
+tells
+.I perl
+to search for the script if necessary.
+After
+.I perl
+locates the script, it parses the lines and ignores them because
 the variable $running_under_some_shell is never true.
+A better construct than $* would be ${1+"$@"}, which handles embedded spaces
+and such in the filenames, but doesn't work if the script is being interpreted
+by csh.
+In order to start up sh rather than csh, some systems may have to replace the
+#! line with a line containing just
+a colon, which will be politely ignored by perl.
+.TP 5
+.B \-u
+causes
+.I perl
+to dump core after compiling your script.
+You can then take this core dump and turn it into an executable file
+by using the undump program (not supplied).
+This speeds startup at the expense of some disk space (which you can
+minimize by stripping the executable).
+(Still, a "hello world" executable comes out to about 200K on my machine.)
+If you are going to run your executable as a set-id program then you
+should probably compile it using taintperl rather than normal perl.
+If you want to execute a portion of your script before dumping, use the
+dump operator instead.
 .TP 5
 .B \-U
-allows perl to do unsafe operations.
+allows
+.I perl
+to do unsafe operations.
 Currently the only \*(L"unsafe\*(R" operation is the unlinking of directories while
 running as superuser.
 .TP 5
 .B \-v
-prints the version and patchlevel of your perl executable.
+prints the version and patchlevel of your
+.I perl
+executable.
 .TP 5
 .B \-w
 prints warnings about identifiers that are mentioned only once, and scalar
 variables that are used before being set.
 Also warns about redefined subroutines, and references to undefined
-subroutines and filehandles.
+filehandles or filehandles opened readonly that you are attempting to
+write on.
+Also warns you if you use == on values that don't look like numbers, and if
+your subroutines recurse more than 100 deep.
 .Sh "Data Types and Objects"
 .PP
-Perl has about two and a half data types: scalars, arrays of scalars, and
-associative arrays.
-Scalars and arrays of scalars are first class objects, for the most part,
-in the sense that they can be used as a whole as values in an expression.
-Associative arrays can only be accessed on an association by association basis;
-they don't have a value as a whole (at least not yet).
+.I Perl
+has three data types: scalars, arrays of scalars, and
+associative arrays of scalars.
+Normal arrays are indexed by number, and associative arrays by string.
 .PP
-Scalars are interpreted as strings or numbers as appropriate.
+The interpretation of operations and values in perl sometimes
+depends on the requirements
+of the context around the operation or value.
+There are three major contexts: string, numeric and array.
+Certain operations return array values
+in contexts wanting an array, and scalar values otherwise.
+(If this is true of an operation it will be mentioned in the documentation
+for that operation.)
+Operations which return scalars don't care whether the context is looking
+for a string or a number, but
+scalar variables and values are interpreted as strings or numbers
+as appropriate to the context.
 A scalar is interpreted as TRUE in the boolean sense if it is not the null
 string or 0.
-Booleans returned by operators are 1 for true and '0' or '' (the null
+Booleans returned by operators are 1 for true and 0 or \'\' (the null
 string) for false.
 .PP
+There are actually two varieties of null string: defined and undefined.
+Undefined null strings are returned when there is no real value for something,
+such as when there was an error, or at end of file, or when you refer
+to an uninitialized variable or element of an array.
+An undefined null string may become defined the first time you access it, but
+prior to that you can use the defined() operator to determine whether the
+value is defined or not.
+.PP
 References to scalar variables always begin with \*(L'$\*(R', even when referring
 to a scalar that is part of an array.
 Thus:
@@ -330,19 +447,28 @@ Thus:
 .ne 3
     $days      \h'|2i'# a simple scalar variable
     $days[28]  \h'|2i'# 29th element of array @days
-    $days{'Feb'}\h'|2i'# one value from an associative array
+    $days{\'Feb\'}\h'|2i'# one value from an associative array
     $#days     \h'|2i'# last index of array @days
 
-but entire arrays are denoted by \*(L'@\*(R':
+but entire arrays or array slices are denoted by \*(L'@\*(R':
 
     @days      \h'|2i'# ($days[0], $days[1],\|.\|.\|. $days[n])
+    @days[3,4,5]\h'|2i'# same as @days[3.\|.5]
+    @days{'a','c'}\h'|2i'# same as ($days{'a'},$days{'c'})
+
+and entire associative arrays are denoted by \*(L'%\*(R':
 
+    %days      \h'|2i'# (key1, val1, key2, val2 .\|.\|.)
 .fi
 .PP
-Any of these five constructs may server as an lvalue,
+Any of these eight constructs may serve as an lvalue,
 that is, may be assigned to.
-(You may also use an assignment to one of these lvalues as an lvalue in
-certain contexts\*(--see s, tr and chop.)
+(It also turns out that an assignment is itself an lvalue in
+certain contexts\*(--see examples under s, tr and chop.)
+Assignment to a scalar evaluates the righthand side in a scalar context,
+while assignment to an array or array slice evaluates the righthand side
+in an array context.
+.PP
 You may find the length of array @days by evaluating
 \*(L"$#days\*(R", as in
 .IR csh .
@@ -367,76 +493,246 @@ The following are exactly equivalent
 
 .fi
 .PP
+If you evaluate an array in a scalar context, it returns the length of
+the array.
+The following is always true:
+.nf
+
+       @whatever == $#whatever \- $[ + 1;
+
+.fi
+.PP
+Multi-dimensional arrays are not directly supported, but see the discussion
+of the $; variable later for a means of emulating multiple subscripts with
+an associative array.
+You could also write a subroutine to turn multiple subscripts into a single
+subscript.
+.PP
 Every data type has its own namespace.
 You can, without fear of conflict, use the same name for a scalar variable,
 an array, an associative array, a filehandle, a subroutine name, and/or
 a label.
-Since variable and array references always start with \*(L'$\*(R'
-or \*(L'@\*(R', the \*(L"reserved\*(R" words aren't in fact reserved
+Since variable and array references always start with \*(L'$\*(R', \*(L'@\*(R',
+or \*(L'%\*(R', the \*(L"reserved\*(R" words aren't in fact reserved
 with respect to variable names.
 (They ARE reserved with respect to labels and filehandles, however, which
 don't have an initial special character.
-Hint: you could say open(LOG,'logfile') rather than open(log,'logfile').)
+Hint: you could say open(LOG,\'logfile\') rather than open(log,\'logfile\').
+Using uppercase filehandles also improves readability and protects you
+from conflict with future reserved words.)
 Case IS significant\*(--\*(L"FOO\*(R", \*(L"Foo\*(R" and \*(L"foo\*(R" are all
 different names.
 Names which start with a letter may also contain digits and underscores.
 Names which do not start with a letter are limited to one character,
 e.g. \*(L"$%\*(R" or \*(L"$$\*(R".
-(Many one character names have a predefined significance to
-.I perl.
+(Most of the one character names have a predefined significance to
+.IR perl .
 More later.)
 .PP
+Numeric literals are specified in any of the usual floating point or
+integer formats:
+.nf
+
+.ne 5
+    12345
+    12345.67
+    .23E-10
+    0xffff     # hex
+    0377       # octal
+
+.fi
 String literals are delimited by either single or double quotes.
 They work much like shell quotes:
 double-quoted string literals are subject to backslash and variable
-substitution; single-quoted strings are not.
+substitution; single-quoted strings are not (except for \e\' and \e\e).
 The usual backslash rules apply for making characters such as newline, tab, etc.
 You can also embed newlines directly in your strings, i.e. they can end on
 a different line than they begin.
 This is nice, but if you forget your trailing quote, the error will not be
-reported until perl finds another line containing the quote character, which
+reported until
+.I perl
+finds another line containing the quote character, which
 may be much further on in the script.
-Variable substitution inside strings is limited (currently) to simple scalar variables.
+Variable substitution inside strings is limited to scalar variables, normal
+array values, and array slices.
+(In other words, identifiers beginning with $ or @, followed by an optional
+bracketed expression as a subscript.)
 The following code segment prints out \*(L"The price is $100.\*(R"
 .nf
 
 .ne 2
-    $Price = '$100';\h'|3.5i'# not interpreted
+    $Price = \'$100\';\h'|3.5i'# not interpreted
     print "The price is $Price.\e\|n";\h'|3.5i'# interpreted
 
 .fi
 Note that you can put curly brackets around the identifier to delimit it
 from following alphanumerics.
+Also note that a single quoted string must be separated from a preceding
+word by a space, since single quote is a valid character in an identifier
+(see Packages).
 .PP
+Array values are interpolated into double-quoted strings by joining all the
+elements of the array with the delimiter specified in the $" variable,
+space by default.
+(Since in versions of perl prior to 3.0 the @ character was not a metacharacter
+in double-quoted strings, the interpolation of @array, $array[EXPR],
+@array[LIST], $array{EXPR}, or @array{LIST} only happens if array is
+referenced elsewhere in the program or is predefined.)
+The following are equivalent:
+.nf
+
+.ne 4
+       $temp = join($",@ARGV);
+       system "echo $temp";
+
+       system "echo @ARGV";
+
+.fi
+Within search patterns (which also undergo double-quotish substitution)
+there is a bad ambiguity:  Is /$foo[bar]/ to be
+interpreted as /${foo}[bar]/ (where [bar] is a character class for the
+regular expression) or as /${foo[bar]}/ (where [bar] is the subscript to
+array @foo)?
+If @foo doesn't otherwise exist, then it's obviously a character class.
+If @foo exists, perl takes a good guess about [bar], and is almost always right.
+If it does guess wrong, or if you're just plain paranoid,
+you can force the correct interpretation with curly brackets as above.
+.PP
+A line-oriented form of quoting is based on the shell here-is syntax.
+Following a << you specify a string to terminate the quoted material, and all lines
+following the current line down to the terminating string are the value
+of the item.
+The terminating string may be either an identifier (a word), or some
+quoted text.
+If quoted, the type of quotes you use determines the treatment of the text,
+just as in regular quoting.
+An unquoted identifier works like double quotes.
+There must be no space between the << and the identifier.
+(If you put a space it will be treated as a null identifier, which is
+valid, and matches the first blank line\*(--see Merry Christmas example below.)
+The terminating string must appear by itself (unquoted and with no surrounding
+whitespace) on the terminating line.
+.nf
+
+       print <<EOF;            # same as above
+The price is $Price.
+EOF
+
+       print <<"EOF";          # same as above
+The price is $Price.
+EOF
+
+       print << x 10;          # null identifier is delimiter
+Merry Christmas!
+
+       print <<`EOC`;          # execute commands
+echo hi there
+echo lo there
+EOC
+
+       print <<foo, <<bar;     # you can stack them
+I said foo.
+foo
+I said bar.
+bar
+
+.fi
 Array literals are denoted by separating individual values by commas, and
-enclosing the list in parentheses.
+enclosing the list in parentheses:
+.nf
+
+       (LIST)
+
+.fi
 In a context not requiring an array value, the value of the array literal
 is the value of the final element, as in the C comma operator.
 For example,
 .nf
 
 .ne 4
-    @foo = ('cc', '\-E', $bar);
+    @foo = (\'cc\', \'\-E\', $bar);
 
 assigns the entire array value to array foo, but
 
-    $foo = ('cc', '\-E', $bar);
+    $foo = (\'cc\', \'\-E\', $bar);
 
 .fi
 assigns the value of variable bar to variable foo.
+Note that the value of an actual array in a scalar context is the length
+of the array; the following assigns to $foo the value 3:
+.nf
+
+.ne 2
+    @foo = (\'cc\', \'\-E\', $bar);
+    $foo = @foo;               # $foo gets 3
+
+.fi
+You may have an optional comma before the closing parenthesis of an
+array literal, so that you can say:
+.nf
+
+    @foo = (
+       1,
+       2,
+       3,
+    );
+
+.fi
+When a LIST is evaluated, each element of the list is evaluated in
+an array context, and the resulting array value is interpolated into LIST
+just as if each individual element were a member of LIST.  Thus arrays
+lose their identity in a LIST\*(--the list
+
+       (@foo,@bar,&SomeSub)
+
+contains all the elements of @foo followed by all the elements of @bar,
+followed by all the elements returned by the subroutine named SomeSub.
+.PP
+A list value may also be subscripted like a normal array.
+Examples:
+.nf
+
+       $time = (stat($file))[8];       # stat returns array value
+       $digit = ('a','b','c','d','e','f')[$digit-10];
+       return (pop(@foo),pop(@foo))[0];
+
+.fi
+.PP
 Array lists may be assigned to if and only if each element of the list
 is an lvalue:
 .nf
 
     ($a, $b, $c) = (1, 2, 3);
 
-    ($map{'red'}, $map{'blue'}, $map{'green'}) = (0x00f, 0x0f0, 0xf00);
+    ($map{\'red\'}, $map{\'blue\'}, $map{\'green\'}) = (0x00f, 0x0f0, 0xf00);
+
+The final element may be an array or an associative array:
+
+    ($a, $b, @rest) = split;
+    local($a, $b, %rest) = @_;
 
 .fi
-Array assignment returns the number of elements assigned.
+You can actually put an array anywhere in the list, but the first array
+in the list will soak up all the values, and anything after it will get
+a null value.
+This may be useful in a local().
 .PP
-Numeric literals are specified in any of the usual floating point or
-integer formats.
+An associative array literal contains pairs of values to be interpreted
+as a key and a value:
+.nf
+
+.ne 2
+    # same as map assignment above
+    %map = ('red',0x00f,'blue',0x0f0,'green',0xf00);
+
+.fi
+Array assignment in a scalar context returns the number of elements
+produced by the expression on the right side of the assignment:
+.nf
+
+       $x = (($foo,$bar) = (3,2,1));   # set $x to 3, not 2
+
+.fi
 .PP
 There are several other pseudo-literals that you should know about.
 If a string is enclosed by backticks (grave accents), it first undergoes
@@ -453,9 +749,10 @@ in the command from interpretation.
 To pass a $ through to the shell you need to hide it with a backslash.
 .PP
 Evaluating a filehandle in angle brackets yields the next line
-from that file (newline included, so it's never false until EOF).
+from that file (newline included, so it's never false until EOF, at
+which time an undefined value is returned).
 Ordinarily you must assign that value to a variable,
-but there is one situation where in which an automatic assignment happens.
+but there is one situation where an automatic assignment happens.
 If (and only if) the input symbol is the only thing inside the conditional of a
 .I while
 loop, the value is
@@ -467,18 +764,27 @@ script you write.)
 Anyway, the following lines are equivalent to each other:
 .nf
 
-.ne 3
-    while ($_ = <stdin>) {
-    while (<stdin>) {
-    for (\|;\|<stdin>;\|) {
+.ne 5
+    while ($_ = <STDIN>) { print; }
+    while (<STDIN>) { print; }
+    for (\|;\|<STDIN>;\|) { print; }
+    print while $_ = <STDIN>;
+    print while <STDIN>;
 
 .fi
 The filehandles
+.IR STDIN ,
+.I STDOUT
+and
+.I STDERR
+are predefined.
+(The filehandles
 .IR stdin ,
 .I stdout
 and
 .I stderr
-are predefined.
+will also work except in packages, where they would be interpreted as
+local identifiers rather than global.)
 Additional filehandles may be created with the
 .I open
 function.
@@ -492,7 +798,7 @@ The null filehandle <> is special and can be used to emulate the behavior of
 Input from <> comes either from standard input, or from each file listed on
 the command line.
 Here's how it works: the first time <> is evaluated, the ARGV array is checked,
-and if it is null, $ARGV[0] is set to '-', which when opened gives you standard
+and if it is null, $ARGV[0] is set to \'-\', which when opened gives you standard
 input.
 The ARGV array is then processed as a list of filenames.
 The loop
@@ -506,7 +812,7 @@ The loop
 .ne 10
 is equivalent to
 
-       unshift(@ARGV, '\-') \|if \|$#ARGV < $[;
+       unshift(@ARGV, \'\-\') \|if \|$#ARGV < $[;
        while ($ARGV = shift) {
                open(ARGV, $ARGV);
                while (<ARGV>) {
@@ -545,7 +851,8 @@ put a loop on the front like this:
 .fi
 The <> symbol will return FALSE only once.
 If you call it again after this it will assume you are processing another
-@ARGV list, and if you haven't set @ARGV, will input from stdin.
+@ARGV list, and if you haven't set @ARGV, will input from
+.IR STDIN .
 .PP
 If the string inside the angle brackets is a reference to a scalar variable
 (e.g. <$foo>),
@@ -564,25 +871,26 @@ Example:
 
 .ne 3
        while (<*.c>) {
-               chmod 0644,$_;
+               chmod 0644, $_;
        }
 
 is equivalent to
 
 .ne 5
-       open(foo,"echo *.c | tr -s ' \et\er\ef' '\e\e012\e\e012\e\e012\e\e012'|");
+       open(foo, "echo *.c | tr \-s \' \et\er\ef\' \'\e\e012\e\e012\e\e012\e\e012\'|");
        while (<foo>) {
                chop;
-               chmod 0644,$_;
+               chmod 0644, $_;
        }
 
 .fi
 In fact, it's currently implemented that way.
-(Which means it will not work on filenames with spaces in them.)
+(Which means it will not work on filenames with spaces in them unless
+you have /bin/csh on your machine.)
 Of course, the shortest way to do the above is:
 .nf
 
-       chmod 0644,<*.c>;
+       chmod 0644, <*.c>;
 
 .fi
 .Sh "Syntax"
@@ -594,7 +902,9 @@ The only things that need to be declared in
 .I perl
 are report formats and subroutines.
 See the sections below for more information on those declarations.
-All objects are assumed to start with a null or 0 value.
+All uninitialized user-created objects are assumed to
+start with a null or 0 value until they
+are defined by some explicit operation such as assignment.
 The sequence of commands is executed just once, unlike in
 .I sed
 and
@@ -610,7 +920,8 @@ or
 switch.)
 .PP
 A declaration can be put anywhere a command can, but has no effect on the
-execution of the primary sequence of commands.
+execution of the primary sequence of commands--declarations all take effect
+at compile time.
 Typically all the declarations are put at the beginning or the end of the script.
 .PP
 .I Perl
@@ -650,11 +961,11 @@ The following all do the same thing:
 .nf
 
 .ne 5
-    if (!open(foo)) { die "Can't open $foo"; }
-    die "Can't open $foo" unless open(foo);
-    open(foo) || die "Can't open $foo";        # foo or bust!
-    open(foo) ? die "Can't open $foo" : 'hi mom';
-                           # a bit exotic, that last one
+       if (!open(foo)) { die "Can't open $foo: $!"; }
+       die "Can't open $foo: $!" unless open(foo);
+       open(foo) || die "Can't open $foo: $!"; # foo or bust!
+       open(foo) ? \'hi mom\' : die "Can't open $foo: $!";
+                               # a bit exotic, that last one
 
 .fi
 .PP
@@ -681,7 +992,7 @@ The LABEL is optional, and if present, consists of an identifier followed by
 a colon.
 The LABEL identifies the loop for the loop control statements
 .IR next ,
-.I last
+.IR last ,
 and
 .I redo
 (see below).
@@ -751,14 +1062,18 @@ Examples:
                $elem *= 2;
        }
 
-       for ((10,9,8,7,6,5,4,3,2,1,'BOOM')) {
-           print $_,"\en"; sleep(1);
+.ne 3
+       for ((10,9,8,7,6,5,4,3,2,1,\'BOOM\')) {
+               print $_, "\en"; sleep(1);
        }
 
+       for (1..15) { print "Merry Christmas\en"; }
+
 .ne 3
-       foreach $item (split(/:[\e\e\en:]*/,$ENV{'TERMCAP'}) {
+       foreach $item (split(/:[\e\e\en:]*/, $ENV{\'TERMCAP\'}) {
                print "Item: $item\en";
        }
+
 .fi
 .PP
 The BLOCK by itself (labeled or not) is equivalent to a loop that executes
@@ -773,28 +1088,67 @@ This construct is particularly nice for doing case structures.
 
 .ne 6
        foo: {
-               if (/abc/) { $abc = 1; last foo; }
-               if (/def/) { $def = 1; last foo; }
-               if (/xyz/) { $xyz = 1; last foo; }
+               if (/^abc/) { $abc = 1; last foo; }
+               if (/^def/) { $def = 1; last foo; }
+               if (/^xyz/) { $xyz = 1; last foo; }
                $nothing = 1;
        }
 
 .fi
-It's also nice for exiting subroutines early.
-Note the double curly brackets:
+There is no official switch statement in perl, because there
+are already several ways to write the equivalent.
+In addition to the above, you could write
 .nf
 
+.ne 6
+       foo: {
+               $abc = 1, last foo  if /^abc/;
+               $def = 1, last foo  if /^def/;
+               $xyz = 1, last foo  if /^xyz/;
+               $nothing = 1;
+       }
+
+or
+
+.ne 6
+       foo: {
+               /^abc/ && do { $abc = 1; last foo; }
+               /^def/ && do { $def = 1; last foo; }
+               /^xyz/ && do { $xyz = 1; last foo; }
+               $nothing = 1;
+       }
+
+or
+
+.ne 6
+       foo: {
+               /^abc/ && ($abc = 1, last foo);
+               /^def/ && ($def = 1, last foo);
+               /^xyz/ && ($xyz = 1, last foo);
+               $nothing = 1;
+       }
+
+or even
+
 .ne 8
-       sub tokenize {{
-               .\|.\|.
-               if (/foo/) {
-                       23;             # return value
-                       last;
-               }
-               .\|.\|.
-       }}
+       if (/^abc/)
+               { $abc = 1; }
+       elsif (/^def/)
+               { $def = 1; }
+       elsif (/^xyz/)
+               { $xyz = 1; }
+       else
+               {$nothing = 1;}
 
 .fi
+As it happens, these are all optimized internally to a switch structure,
+so perl jumps directly to the desired statement, and you needn't worry
+about perl executing a lot of unnecessary statements when you have a string
+of 50 elsifs, as long as you are testing the same simple scalar variable
+using ==, eq, or pattern matching as above.
+(If you're curious as to whether the optimizer has done this for a particular
+case statement, you can use the \-D1024 switch to list the syntax tree
+before execution.)
 .Sh "Simple statements"
 The only kind of simple statement is an expression evaluated for its side
 effects.
@@ -831,7 +1185,7 @@ This is so that you can write loops like:
 
 .ne 4
        do {
-               $_ = <stdin>;
+               $_ = <STDIN>;
                .\|.\|.
        } until $_ \|eq \|".\|\e\|n";
 
@@ -850,12 +1204,16 @@ will be mentioned here.
 Here's what
 .I perl
 has that C doesn't:
+.Ip ** 8 2
+The exponentiation operator.
+.Ip **= 8
+The exponentiation assignment operator.
 .Ip (\|) 8 3
 The null list, used to initialize an array to null.
 .Ip . 8
 Concatenation of two strings.
 .Ip .= 8
-The corresponding assignment operator.
+The concatenation assignment operator.
 .Ip eq 8
 String equality (== is numeric equality).
 For a mnemonic just think of \*(L"eq\*(R" as a string.
@@ -895,66 +1253,85 @@ Returns a string consisting of the left operand repeated the
 number of times specified by the right operand.
 .nf
 
-       print '-' x 80;         # print row of dashes
-       print '-' x80;          # illegal, x80 is identifier
+       print \'\-\' x 80;              # print row of dashes
+       print \'\-\' x80;               # illegal, x80 is identifier
 
-       print "\et" x ($tab/8), ' ' x ($tab%8); # tab over
+       print "\et" x ($tab/8), \' \' x ($tab%8);       # tab over
 
 .fi
 .Ip x= 8
-The corresponding assignment operator.
-.Ip .. 8
-The range operator, which is bistable.
-Each .. operator maintains its own boolean state.
+The repetition assignment operator.
+.Ip .\|. 8
+The range operator, which is really two different operators depending
+on the context.
+In an array context, returns an array of values counting (by ones)
+from the left value to the right value.
+This is useful for writing \*(L"for (1..10)\*(R" loops and for doing
+slice operations on arrays.
+.Sp
+In a scalar context, .\|. returns a boolean value.
+The operator is bistable, like a flip-flop..
+Each .\|. operator maintains its own boolean state.
 It is false as long as its left operand is false.
 Once the left operand is true, the range operator stays true
 until the right operand is true,
 AFTER which the range operator becomes false again.
-(It doesn't become false till the next time the range operator evaluated.
+(It doesn't become false till the next time the range operator is evaluated.
 It can become false on the same evaluation it became true, but it still returns
 true once.)
 The right operand is not evaluated while the operator is in the \*(L"false\*(R" state,
 and the left operand is not evaluated while the operator is in the \*(L"true\*(R" state.
-The .. operator is primarily intended for doing line number ranges after
+The scalar .\|. operator is primarily intended for doing line number ranges
+after
 the fashion of \fIsed\fR or \fIawk\fR.
 The precedence is a little lower than || and &&.
 The value returned is either the null string for false, or a sequence number
 (beginning with 1) for true.
 The sequence number is reset for each range encountered.
-The final sequence number in a range has the string 'E0' appended to it, which
+The final sequence number in a range has the string \'E0\' appended to it, which
 doesn't affect its numeric value, but gives you something to search for if you
 want to exclude the endpoint.
 You can exclude the beginning point by waiting for the sequence number to be
 greater than 1.
-If either operand of .. is static, that operand is implicitly compared to
-the $. variable, the current line number.
+If either operand of scalar .\|. is static, that operand is implicitly compared
+to the $. variable, the current line number.
 Examples:
 .nf
 
-.ne 5
-    if (101 .. 200) { print; } # print 2nd hundred lines
+.ne 6
+As a scalar operator:
+    if (101 .\|. 200) { print; }       # print 2nd hundred lines
 
-    next line if (1 .. /^$/);  # skip header lines
+    next line if (1 .\|. /^$/);        # skip header lines
 
-    s/^/> / if (/^$/ .. eof());        # quote body
+    s/^/> / if (/^$/ .\|. eof());      # quote body
+
+.ne 4
+As an array operator:
+    for (101 .\|. 200) { print; }      # print $_ 100 times
+
+    @foo = @foo[$[ .\|. $#foo];        # an expensive no-op
+    @foo = @foo[$#foo-4 .\|. $#foo];   # slice last 5 items
 
 .fi
 .Ip \-x 8
 A file test.
 This unary operator takes one argument, either a filename or a filehandle,
 and tests the associated file to see if something is true about it.
-If the argument is omitted, tests $_, except for \-t, which tests stdin.
-It returns 1 for true and '' for false.
+If the argument is omitted, tests $_, except for \-t, which tests
+.IR STDIN .
+It returns 1 for true and \'\' for false, or the undefined value if the
+file doesn't exist.
 Precedence is higher than logical and relational operators, but lower than
 arithmetic operators.
 The operator may be any of:
 .nf
        \-r     File is readable by effective uid.
-       \-w     File is writeable by effective uid.
+       \-w     File is writable by effective uid.
        \-x     File is executable by effective uid.
        \-o     File is owned by effective uid.
        \-R     File is readable by real uid.
-       \-W     File is writeable by real uid.
+       \-W     File is writable by real uid.
        \-X     File is executable by real uid.
        \-O     File is owned by real uid.
        \-e     File exists.
@@ -994,8 +1371,8 @@ Example:
        }
 
 .fi
-Note that -s/a/b/ does not do a negated substitution.
-Saying -exp($foo) still works as expected, however\*(--only single letters
+Note that \-s/a/b/ does not do a negated substitution.
+Saying \-exp($foo) still works as expected, however\*(--only single letters
 following a minus are interpreted as file tests.
 .Sp
 The \-T and \-B switches work as follows.
@@ -1005,12 +1382,34 @@ If too many odd characters (>10%) are found, it's a \-B file, otherwise it's a \
 Also, any file containing null in the first block is considered a binary file.
 If \-T or \-B is used on a filehandle, the current stdio buffer is examined
 rather than the first block.
-Since input doesn't work well on binary files you should probably test a
-filehandle before doing any input if you're unsure of the nature of the
-filehandle you've been handed (usually via stdin).
 Both \-T and \-B return TRUE on a null file, or a file at EOF when testing
 a filehandle.
 .PP
+If any of the file tests (or either stat operator) are given the special
+filehandle consisting of a solitary underline, then the stat structure
+of the previous file test (or stat operator) is used, saving a system
+call.
+(This doesn't work with \-t, and you need to remember that lstat and -l
+will leave values in the stat structure for the symbolic link, not the
+real file.)
+Example:
+.nf
+
+       print "Can do.\en" if -r $a || -w _ || -x _;
+
+.ne 9
+       stat($filename);
+       print "Readable\en" if -r _;
+       print "Writable\en" if -w _;
+       print "Executable\en" if -x _;
+       print "Setuid\en" if -u _;
+       print "Setgid\en" if -g _;
+       print "Sticky\en" if -k _;
+       print "Text\en" if -T _;
+       print "Binary\en" if -B _;
+
+.fi
+.PP
 Here is what C has that
 .I perl
 doesn't:
@@ -1032,8 +1431,8 @@ You can say
 .nf
 
 .ne 2
-       'Now is the time for all' . "\|\e\|n" .
-       'good men to come to.'
+       \'Now is the time for all\' . "\|\e\|n" .
+       \'good men to come to.\'
 
 .fi
 and this all reduces to one string internally.
@@ -1043,375 +1442,33 @@ If you increment a variable that is numeric, or that has ever been used in
 a numeric context, you get a normal increment.
 If, however, the variable has only been used in string contexts since it
 was set, and has a value that is not null and matches the
-pattern /^[a-zA-Z]*[0-9]*$/, the increment is done
+pattern /^[a\-zA\-Z]*[0\-9]*$/, the increment is done
 as a string, preserving each character within its range, with carry:
 .nf
 
-       print ++($foo = '99');  # prints '100'
-       print ++($foo = 'a0');  # prints 'a1'
-       print ++($foo = 'Az');  # prints 'Ba'
-       print ++($foo = 'zz');  # prints 'aaa'
+       print ++($foo = \'99\');        # prints \*(L'100\*(R'
+       print ++($foo = \'a0\');        # prints \*(L'a1\*(R'
+       print ++($foo = \'Az\');        # prints \*(L'Ba\*(R'
+       print ++($foo = \'zz\');        # prints \*(L'aaa\*(R'
 
 .fi
 The autodecrement is not magical.
 .PP
-Along with the literals and variables mentioned earlier,
-the following operations can serve as terms in an expression.
-Some of these operations take a LIST as an argument.
-Such a list can consist of any combination of scalar arguments or arrays;
-the arrays will be included in the list as if each individual element were
-interpolated at that point in the list.
-Elements of the LIST should be separated by commas.
-.Ip "/PATTERN/i" 8 4
-Searches a string for a pattern, and returns true (1) or false ('').
-If no string is specified via the =~ or !~ operator,
-the $_ string is searched.
-(The string specified with =~ need not be an lvalue\*(--it may be the result of an expression evaluation, but remember the =~ binds rather tightly.)
-See also the section on regular expressions.
-.Sp
-If you prepend an `m' you can use any pair of characters as delimiters.
-This is particularly useful for matching Unix path names that contain `/'.
-If the final delimiter is followed by the optional letter `i', the matching is
-done in a case-insensitive manner.
-.Sp
-If used in a context that requires an array value, a pattern match returns an
-array consisting of the subexpressions matched by the parens in pattern,
-i.e. ($1, $2, $3.\|.\|.).
-.Sp
-Examples:
-.nf
-
-.ne 4
-    open(tty, '/dev/tty');
-    <tty> \|=~ \|/\|^y\|/i \|&& \|do foo(\|);  # do foo if desired
-
-    if (/Version: \|*\|([0-9.]*\|)\|/\|) { $version = $1; }
-
-    next if m#^/usr/spool/uucp#;
-
-    if (($F1,$F2,$Etc) = ($foo =~ /^(\eS+)\es+(\eS+)\es*(.*)/))
-
-.fi
-This last example splits $foo into the first two words and the remainder
-of the line, and assigns those three fields to $F1, $F2 and $Etc.
-The conditional is true if any variables were assigned, i.e. if the pattern
-matched.
-.Ip "?PATTERN?" 8 4
-This is just like the /pattern/ search, except that it matches only once between
-calls to the
-.I reset
-operator.
-This is a useful optimization when you only want to see the first occurence of
-something in each file of a set of files, for instance.
-.Ip "chdir EXPR" 8 2
-Changes the working directory to EXPR, if possible.
-Returns 1 upon success, 0 otherwise.
-See example under die().
-.Ip "chmod LIST" 8 2
-Changes the permissions of a list of files.
-The first element of the list must be the numerical mode.
-Returns the number of files successfully changed.
-.nf
-
-.ne 2
-       $cnt = chmod 0755,'foo','bar';
-       chmod 0755,@executables;
-
-.fi
-.Ip "chop(VARIABLE)" 8 5
-.Ip "chop" 8
-Chops off the last character of a string and returns it.
-It's used primarily to remove the newline from the end of an input record,
-but is much more efficient than s/\en// because it neither scans nor copies
-the string.
-If VARIABLE is omitted, chops $_.
-Example:
-.nf
-
-.ne 5
-       while (<>) {
-               chop;   # avoid \en on last field
-               @array = split(/:/);
-               .\|.\|.
-       }
-
-.fi
-You can actually chop anything that's an lvalue, including an assignment:
-.nf
-
-       chop($cwd = `pwd`);
-
-.fi
-.Ip "chown LIST" 8 2
-Changes the owner (and group) of a list of files.
-The first two elements of the list must be the NUMERICAL uid and gid,
-in that order.
-Returns the number of files successfully changed.
-.nf
-
-.ne 2
-       $cnt = chown $uid,$gid,'foo','bar';
-       chown $uid,$gid,@filenames;
-
-.fi
-.ne 23
-Here's an example of looking up non-numeric uids:
-.nf
-
-       print "User: ";
-       $user = <stdin>;
-       chop($user);
-       print "Files: "
-       $pattern = <stdin>;
-       chop($pattern);
-       open(pass,'/etc/passwd') || die "Can't open passwd";
-       while (<pass>) {
-               ($login,$pass,$uid,$gid) = split(/:/);
-               $uid{$login} = $uid;
-               $gid{$login} = $gid;
-       }
-       @ary = <$pattern>;      # get filenames
-       if ($uid{$user} eq '') {
-               die "$user not in passwd file";
-       }
-       else {
-               unshift(@ary,$uid{$user},$gid{$user});
-               chown @ary;
-       }
-
-.fi
-.Ip "close(FILEHANDLE)" 8 5
-.Ip "close FILEHANDLE" 8
-Closes the file or pipe associated with the file handle.
-You don't have to close FILEHANDLE if you are immediately going to
-do another open on it, since open will close it for you.
-(See
-.IR open .)
-However, an explicit close on an input file resets the line counter ($.), while
-the implicit close done by
-.I open
-does not.
-Also, closing a pipe will wait for the process executing on the pipe to complete,
-in case you want to look at the output of the pipe afterwards.
-Example:
-.nf
-
-.ne 4
-       open(output,'|sort >foo');      # pipe to sort
-       .\|.\|. # print stuff to output
-       close(output);          # wait for sort to finish
-       open(input,'foo');      # get sort's results
-
-.fi
-FILEHANDLE may be an expression whose value gives the real filehandle name.
-.Ip "crypt(PLAINTEXT,SALT)" 8 6
-Encrypts a string exactly like the crypt() function in the C library.
-Useful for checking the password file for lousy passwords.
-Only the guys wearing white hats should do this.
-.Ip "delete $ASSOC{KEY}" 8 6
-Deletes the specified value from the specified associative array.
-Returns the deleted value;
-The following deletes all the values of an associative array:
-.nf
-
-.ne 3
-       foreach $key (keys(ARRAY)) {
-               delete $ARRAY{$key};
-       }
-
-.fi
-(But it would be faster to use the reset command.)
-.Ip "die EXPR" 8 6
-Prints the value of EXPR to stderr and exits with the current value of $!
-(errno).
-If $! is 0, exits with the value of ($? >> 8) (`command` status).
-If ($? >> 8) is 0, exits with 255.
-Equivalent examples:
-.nf
-
-.ne 3
-       die "Can't cd to spool.\en" unless chdir '/usr/spool/news';
-
-       chdir '/usr/spool/news' || die "Can't cd to spool.\en" 
-
-.fi
-.Sp
-If the value of EXPR does not end in a newline, the current script line
-number and input line number (if any) are also printed, and a newline is
-supplied.
-Hint: sometimes appending \*(L", stopped\*(R" to your message will cause it to make
-better sense when the string \*(L"at foo line 123\*(R" is appended.
-Suppose you are running script \*(L"canasta\*(R".
-.nf
-
-.ne 7
-       die "/etc/games is no good";
-       die "/etc/games is no good, stopped";
-
-produce, respectively
-
-       /etc/games is no good at canasta line 123.
-       /etc/games is no good, stopped at canasta line 123.
-
-.fi
-See also
-.IR exit .
-.Ip "do BLOCK" 8 4
-Returns the value of the last command in the sequence of commands indicated
-by BLOCK.
-When modified by a loop modifier, executes the BLOCK once before testing the
-loop condition.
-(On other statements the loop modifiers test the conditional first.)
-.Ip "do SUBROUTINE (LIST)" 8 3
-Executes a SUBROUTINE declared by a
-.I sub
-declaration, and returns the value
-of the last expression evaluated in SUBROUTINE.
-If you pass arrays as part of LIST you may wish to pass the length
-of the array in front of each array.
-(See the section on subroutines later on.)
-SUBROUTINE may be a scalar variable, in which case the variable contains
-the name of the subroutine to execute.
-The parentheses are required to avoid confusion with the next form of \*(L"do\*(R".
-.Ip "do EXPR" 8 3
-Uses the value of EXPR as a filename and executes the contents of the file
-as a perl script.
-It's primary use is to include subroutines from a perl subroutine library.
-.nf
-       do 'stat.pl';
-
-is just like
-
-       eval `cat stat.pl`;
-
-.fi
-except that it's more efficient, more concise, keeps track of the current
-filename for error messages, and searches all the -I libraries if the file
-isn't in the current directory (see also the @INC array in Predefined Names).
-It's the same, however, in that it does reparse the file every time you
-call it, so if you are going to use the file inside a loop you might prefer
-to use #include, at the expense of a little more startup time.
-(The main problem with #include is that cpp doesn't grok # comments--a
-workaround is to use \*(L";#\*(R" for standalone comments.)
-Note that the following are NOT equivalent:
-.nf
-
-.ne 2
-       do $foo;        # eval a file
-       do $foo();      # call a subroutine
-
-.fi
-.Ip "each(ASSOC_ARRAY)" 8 6
-Returns a 2 element array consisting of the key and value for the next
-value of an associative array, so that you can iterate over it.
-Entries are returned in an apparently random order.
-When the array is entirely read, a null array is returned (which when
-assigned produces a FALSE (0) value).
-The next call to each() after that will start iterating again.
-The iterator can be reset only by reading all the elements from the array.
-You must not modify the array while iterating over it.
-There is a single iterator for each associative array, shared by all
-each(), keys() and values() function calls in the program.
-The following prints out your environment like the printenv program, only
-in a different order:
-.nf
-
-.ne 3
-       while (($key,$value) = each(ENV)) {
-               print "$key=$value\en";
-       }
-
-.fi
-See also keys() and values().
-.Ip "eof(FILEHANDLE)" 8 8
-.Ip "eof" 8
-Returns 1 if the next read on FILEHANDLE will return end of file, or if
-FILEHANDLE is not open.
-FILEHANDLE may be an expression whose value gives the real filehandle name.
-An eof without an argument returns the eof status for the last file read.
-Empty parentheses () may be used to indicate the pseudo file formed of the
-files listed on the command line, i.e. eof() is reasonable to use inside
-a while (<>) loop to detect the end of only the last file.
-Use eof(ARGV) or eof without the parens to test EACH file in a while (<>) loop.
-Examples:
-.nf
-
-.ne 7
-       # insert dashes just before last line of last file
-       while (<>) {
-               if (eof()) {
-                       print "--------------\en";
-               }
-               print;
-       }
-
-.ne 7
-       # reset line numbering on each input file
-       while (<>) {
-               print "$.\et$_";
-               if (eof) {      # Not eof().
-                       close(ARGV);
-               }
-       }
+The range operator (in an array context) makes use of the magical
+autoincrement algorithm if the minimum and maximum are strings.
+You can say
 
-.fi
-.Ip "eval EXPR" 8 6
-EXPR is parsed and executed as if it were a little perl program.
-It is executed in the context of the current perl program, so that
-any variable settings, subroutine or format definitions remain afterwards.
-The value returned is the value of the last expression evaluated, just
-as with subroutines.
-If there is a syntax error or runtime error, a null string is returned by
-eval, and $@ is set to the error message.
-If there was no error, $@ is null.
-If EXPR is omitted, evaluates $_.
-.Ip "exec LIST" 8 6
-If there is more than one argument in LIST,
-calls execvp() with the arguments in LIST.
-If there is only one argument, the argument is checked for shell metacharacters.
-If there are any, the entire argument is passed to /bin/sh -c for parsing.
-If there are none, the argument is split into words and passed directly to
-execvp(), which is more efficient.
-Note: exec (and system) do not flush your output buffer, so you may need to
-set $| to avoid lost output.
-Examples:
-.nf
+       @alphabet = (\'A\' .. \'Z\');
 
-       exec '/bin/echo', 'Your arguments are: ', @ARGV;
-       exec "sort $outfile | uniq";
+to get all the letters of the alphabet, or
 
-.fi
-.Ip "exit EXPR" 8 6
-Evaluates EXPR and exits immediately with that value.
-Example:
-.nf
+       $hexdigit = (0 .. 9, \'a\' .. \'f\')[$num & 15];
 
-.ne 2
-       $ans = <stdin>;
-       exit 0 \|if \|$ans \|=~ \|/\|^[Xx]\|/\|;
+to get a hexadecimal digit, or
 
-.fi
-See also
-.IR die .
-.Ip "exp(EXPR)" 8 3
-Returns e to the power of EXPR.
-.Ip "fork" 8 4
-Does a fork() call.
-Returns the child pid to the parent process and 0 to the child process.
-Note: unflushed buffers remain unflushed in both processes, which means
-you may need to set $| to avoid duplicate output.
-.Ip "gmtime(EXPR)" 8 4
-Converts a time as returned by the time function to a 9-element array with
-the time analyzed for the Greenwich timezone.
-Typically used as follows:
-.nf
+       @z2 = (\'01\' .. \'31\');  print @z2[$mday];
 
-.ne 3
-    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
-       = gmtime(time);
-
-.fi
-All array elements are numeric, and come straight out of a struct tm.
-In particular this means that $mon has the range 0..11 and $wday has the
-range 0..6.
-''' End of part 1
+to get dates with leading zeros.
+(If the final value specified is not in the sequence that the magical increment
+would produce, the sequence goes until the next value would be longer than
+the final value specified.)