Add test for grep() and wantarray
[p5sagit/p5-mst-13.2.git] / pod / perlfunc.pod
index 1148176..6825d22 100644 (file)
@@ -56,9 +56,7 @@ Remember the following rule:
 
 =over 8
 
-=item  
-
-I<THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!>
+=item  I<THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!>
 
 =back
 
@@ -193,12 +191,10 @@ operator which can be used in expressions.
 
 dbmclose, dbmopen
 
-
 =back
 
 =head2 Alphabetical Listing of Perl Functions
 
-
 =over 8
 
 =item -X FILEHANDLE
@@ -283,8 +279,8 @@ file, or a file at EOF when testing a filehandle.  Because you have to
 read a file to do the C<-T> test, on most occasions you want to use a C<-f>
 against the file first, as in C<next unless -f $file && -T $file>.
 
-If any of the file tests (or either the stat() or lstat() operators) are given the
-special filehandle consisting of a solitary underline, then the stat
+If any of the file tests (or either the stat() or lstat() operators) 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 C<-t>, and you need to remember
 that lstat() and C<-l> will leave values in the stat structure for the
@@ -340,7 +336,7 @@ fail with $! set to EINTR because Perl sets up signal handlers to
 restart system calls on some systems.  Using eval/die always works.
 
     eval {
-       local $SIG{ALRM} = sub { die "alarm\n" };       # NB \n required
+       local $SIG{ALRM} = sub { die "alarm\n" };       # NB \n required
        alarm $timeout;
        $nread = sysread SOCKET, $buffer, $size;
        alarm 0;
@@ -357,6 +353,11 @@ restart system calls on some systems.  Using eval/die always works.
 
 Returns the arctangent of Y/X in the range -PI to PI.
 
+For the tangent operation, you may use the POSIX::tan()
+function, or use the familiar relation:
+
+    sub tan { sin($_[0]) / cos($_[0])  }
+
 =item bind SOCKET,NAME
 
 Binds a network address to a socket, just as the bind system call
@@ -382,7 +383,7 @@ is taken as the name of the filehandle.
 
 =item bless REF
 
-This function tells the referenced object (passed as REF) that it is now
+This function tells the thingy referenced by REF that it is now
 an object in the CLASSNAME package--or the current package if no CLASSNAME
 is specified, which is often the case.  It returns the reference for
 convenience, because a bless() is often the last thing in a constructor.
@@ -395,8 +396,9 @@ blessing (and blessings) of objects.
 =item caller
 
 Returns the context of the current subroutine call.  In a scalar context,
-returns TRUE if there is a caller, that is, if we're in a subroutine or
-eval() or require(), and FALSE otherwise.  In a list context, returns
+returns the caller's package name if there is a caller, that is, if
+we're in a subroutine or eval() or require(), and the undefined value
+otherwise.  In a list context, returns
 
     ($package, $filename, $line) = caller;
 
@@ -404,8 +406,17 @@ With EXPR, it returns some extra information that the debugger uses to
 print a stack trace.  The value of EXPR indicates how many call frames
 to go back before the current one.
 
-    ($package, $filename, $line,
-     $subroutine, $hasargs, $wantargs) = caller($i);
+    ($package, $filename, $line, $subroutine, 
+     $hasargs, $wantarray, $evaltext, $is_require) = caller($i);
+
+Here $subroutine may be C<"(eval)"> if the frame is not a subroutine
+call, but C<L<eval>>. In such a case additional elements $evaltext and
+$is_require are set: $is_require is true if the frame is created by
+C<L<require>> or C<L<use>> statement, $evaltext contains the text of
+C<L<eval EXPR>> statement. In particular, for C<L<eval BLOCK>>
+statement $filename is C<"(eval)">, but $evaltext is undefined. (Note
+also that C<L<use>> statement creates a C<L<require>> frame inside
+an C<L<eval EXPR>>) frame.
 
 Furthermore, when called from within the DB package, caller returns more
 detailed information: it sets the list variable @DB::args to be the
@@ -434,12 +445,12 @@ number.  Returns the number of files successfully changed.
 
 This is a slightly safer version of chop (see below).  It removes any
 line ending that corresponds to the current value of C<$/> (also known as
-$INPUT_RECORD_SEPARATOR in the C<English> module).  It returns the number
-of characters removed.  It's often used to remove the newline from the
-end of an input record when you're worried that the final record may be
-missing its newline.  When in paragraph mode (C<$/ = "">), it removes all
-trailing newlines from the string.  If VARIABLE is omitted, it chomps
-$_.  Example:
+$INPUT_RECORD_SEPARATOR in the C<English> module).  It returns the total
+number of characters removed from all its arguments.  It's often used to
+remove the newline from the end of an input record when you're worried
+that the final record may be missing its newline.  When in paragraph mode
+(C<$/ = "">), it removes all trailing newlines from the string.  If
+VARIABLE is omitted, it chomps $_.  Example:
 
     while (<>) {
        chomp;  # avoid \n on last field
@@ -527,7 +538,7 @@ If NUMBER is omitted, uses $_.
 This function works as the system call by the same name: it makes the
 named directory the new root directory for all further pathnames that
 begin with a "/" by your process and all of its children.  (It doesn't
-change your current working directory is unaffected.)  For security
+change your current working directory, which is unaffected.)  For security
 reasons, this call is restricted to the superuser.  If FILENAME is
 omitted, does chroot to $_.
 
@@ -577,6 +588,11 @@ statement).
 Returns the cosine of EXPR (expressed in radians).  If EXPR is omitted
 takes cosine of $_.
 
+For the inverse cosine operation, you may use the POSIX::acos()
+function, or use this relation:
+
+    sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) }
+
 =item crypt PLAINTEXT,SALT
 
 Encrypts a string exactly like the crypt(3) function in the C library
@@ -691,6 +707,24 @@ you should use defined() only when you're questioning the integrity
 of what you're trying to do.  At other times, a simple comparison to
 0 or "" is what you want.
 
+Another surprise is that using defined() on an entire array or 
+hash reports whether memory for that aggregate has ever been
+allocated.  So an array you set to the empty list appears undefined
+initially, and one that once was full and that you then set to 
+the empty list still appears defined.  You should instead use a 
+simple test for size:
+
+    if (@an_array) { print "has array elements\n" }
+    if (%a_hash)   { print "has hash members\n"   }
+
+Using undef() on these, however, does clear their memory and then report
+them as not defined anymore, but you shoudln't do that unless you don't
+plan to use them again, because it saves time when you load them up
+again to have memory already ready to be filled.
+
+This counter-intuitive behaviour of defined() on aggregates may be
+changed, fixed, or broken in a future release of Perl.
+
 =item delete EXPR
 
 Deletes the specified key(s) and their associated values from a hash
@@ -721,10 +755,10 @@ hash element lookup or hash slice:
 
 Outside of an eval(), prints the value of LIST to C<STDERR> and exits with
 the current value of C<$!> (errno).  If C<$!> is 0, exits with the value of
-C<($? E<gt>E<gt> 8)> (back-tick `command` status).  If C<($? E<gt>E<gt> 8)> is 0,
-exits with 255.  Inside an eval(), the error message is stuffed into C<$@>,
-and the eval() is terminated with the undefined value; this makes die()
-the way to raise an exception.
+C<($? E<gt>E<gt> 8)> (back-tick `command` status).  If C<($? E<gt>E<gt> 8)>
+is 0, exits with 255.  Inside an eval(), the error message is stuffed into
+C<$@>, and the eval() is terminated with the undefined value; this makes
+die() the way to raise an exception.
 
 Equivalent examples:
 
@@ -747,6 +781,12 @@ produce, respectively
 
 See also exit() and warn().
 
+You can arrange for a callback to be called just before the die() does
+its deed, by setting the C<$SIG{__DIE__}> hook.  The associated handler
+will be called with the error text and can change the error message, if
+it sees fit, by calling die() again.  See L<perlvar> for details on
+setting C<%SIG> entries, and eval() for some examples.
+
 =item do BLOCK
 
 Not really a function.  Returns the value of the last command in the
@@ -892,8 +932,11 @@ context of the eval.
 If there is a syntax error or runtime error, or a die() statement is
 executed, an undefined value is returned by eval(), and C<$@> is set to the
 error message.  If there was no error, C<$@> is guaranteed to be a null
-string.  If EXPR is omitted, evaluates $_.  The final semicolon, if
-any, may be omitted from the expression.
+string.  If EXPR is omitted, evaluates C<$_>.  The final semicolon, if
+any, may be omitted from the expression.  Beware that using eval()
+neither silences perl from printing warnings to STDERR, nor does it
+stuff the text of warning messages into C<$@>.  To do either of those,
+you have to use the C<$SIG{__WARN__}> facility.  See warn() and L<perlvar>.
 
 Note that, because eval() traps otherwise-fatal errors, it is useful for
 determining whether a particular feature (such as socket() or symlink())
@@ -917,6 +960,24 @@ Examples:
     # a run-time error
     eval '$answer =';  # sets $@
 
+When using the eval{} form as an exception trap in libraries, you may
+wish not to trigger any C<__DIE__> hooks that user code may have
+installed.  You can use the C<local $SIG{__DIE__}> construct for this
+purpose, as shown in this example:
+
+    # a very private exception trap for divide-by-zero
+    eval { local $SIG{'__DIE__'}; $answer = $a / $b; }; warn $@ if $@;
+
+This is especially significant, given that C<__DIE__> hooks can call
+die() again, which has the effect of changing their error messages:
+
+    # __DIE__ hooks may modify error messages
+    {
+       local $SIG{'__DIE__'} = sub { (my $x = $_[0]) =~ s/foo/bar/g; die $x };
+       eval { die "foo foofs here" };
+       print $@ if $@;                # prints "bar barfs here"
+    }
+
 With an eval(), you should be especially careful to remember what's 
 being looked at when:
 
@@ -998,7 +1059,14 @@ are called before exit.)  Example:
     $ans = <STDIN>;
     exit 0 if $ans =~ /^[Xx]/;
 
-See also die().  If EXPR is omitted, exits with 0 status.
+See also die().  If EXPR is omitted, exits with 0 status.  The only
+univerally portable values for EXPR are 0 for success and 1 for error;
+all other values are subject to unpredictable interpretation depending
+on the environment in which the Perl program is running.
+
+You shouldn't use exit() to abort a subroutine if there's any chance that
+someone might want to trap whatever error happened.  Use die() instead,
+which can be trapped by an eval().
 
 =item exp EXPR
 
@@ -1029,31 +1097,49 @@ value is taken as the name of the filehandle.
 
 =item flock FILEHANDLE,OPERATION
 
-Calls flock(2) on FILEHANDLE.  See L<flock(2)> for definition of
-OPERATION.  Returns TRUE for success, FALSE on failure.  Will produce a
-fatal error if used on a machine that doesn't implement either flock(2) or
-fcntl(2). The fcntl(2) system call will be automatically used if flock(2)
-is missing from your system.  This makes flock() the portable file locking
-strategy, although it will lock only entire files, not records.  Note also
-that some versions of flock() cannot lock things over the network; you
-would need to use the more system-specific fcntl() for that.
+Calls flock(2), or an emulation of it, on FILEHANDLE.  Returns TRUE for
+success, FALSE on failure.  Will produce a fatal error if used on a
+machine that doesn't implement flock(2), fcntl(2) locking, or lockf(3).
+flock() is Perl's portable file locking interface, although it will lock
+only entire files, not records.
+
+OPERATION is one of LOCK_SH, LOCK_EX, or LOCK_UN, possibly combined with
+LOCK_NB.  These constants are traditionally valued 1, 2, 8 and 4, but
+you can use the symbolic names if you pull them in with an explicit
+request to the Fcntl module.  The names can be requested as a group with
+the :flock tag (or they can be requested individually, of course).
+LOCK_SH requests a shared lock, LOCK_EX requests an exclusive lock, and
+LOCK_UN releases a previously requested lock.  If LOCK_NB is added to
+LOCK_SH or LOCK_EX then flock() will return immediately rather than
+blocking waiting for the lock (check the return status to see if you got
+it).
+
+Note that the emulation built with lockf(3) doesn't provide shared
+locks, and it requires that FILEHANDLE be open with write intent.  These
+are the semantics that lockf(3) implements.  Most (all?) systems
+implement lockf(3) in terms of fcntl(2) locking, though, so the
+differing semantics shouldn't bite too many people.
+
+Note also that some versions of flock() cannot lock things over the
+network; you would need to use the more system-specific fcntl() for
+that.  If you like you can force Perl to ignore your system's flock(2)
+function, and so provide its own fcntl(2)-based emulation, by passing
+the switch C<-Ud_flock> to the F<Configure> program when you configure
+perl.
 
 Here's a mailbox appender for BSD systems.
 
-    $LOCK_SH = 1;
-    $LOCK_EX = 2;
-    $LOCK_NB = 4;
-    $LOCK_UN = 8;
+    use Fcntl ':flock'; # import LOCK_* constants
 
     sub lock {
-       flock(MBOX,$LOCK_EX);
+       flock(MBOX,LOCK_EX);
        # and, in case someone appended
        # while we were waiting...
        seek(MBOX, 0, 2);
     }
 
     sub unlock {
-       flock(MBOX,$LOCK_UN);
+       flock(MBOX,LOCK_UN);
     }
 
     open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}")
@@ -1070,8 +1156,8 @@ See also L<DB_File> for other flock() examples.
 Does a fork(2) system call.  Returns the child pid to the parent process
 and 0 to the child process, or C<undef> if the fork is unsuccessful.
 Note: unflushed buffers remain unflushed in both processes, which means
-you may need to set C<$|> ($AUTOFLUSH in English) or call the 
-autoflush() FileHandle method to avoid duplicate output.
+you may need to set C<$|> ($AUTOFLUSH in English) or call the autoflush()
+method of IO::Handle to avoid duplicate output.
 
 If you fork() without ever waiting on your children, you will accumulate
 zombies:
@@ -1096,6 +1182,11 @@ fork() returns omitted);
 See also L<perlipc> for more examples of forking and reaping
 moribund children.
 
+Note that if your forked child inherits system file descriptors like
+STDIN and STDOUT that are actually connected by a pipe or socket, even
+if you exit, the remote server (such as, say, httpd or rsh) won't think
+you're done.  You should reopen those to /dev/null if it's any issue.
+
 =item format
 
 Declare a picture format with use by the write() function.  For
@@ -1159,18 +1250,20 @@ single-characters, however.  For that, try something more like:
     }
     print "\n";
 
-Determination of whether to whether $BSD_STYLE should be set 
+Determination of whether $BSD_STYLE should be set 
 is left as an exercise to the reader.  
 
+The POSIX::getattr() function can do this more portably on systems
+alleging POSIX compliance.
 See also the C<Term::ReadKey> module from your nearest CPAN site;
-details on CPAN can be found on L<perlmod/CPAN> 
+details on CPAN can be found on L<perlmod/CPAN>.  
 
 =item getlogin
 
 Returns the current login from F</etc/utmp>, if any.  If null, use
 getpwuid().  
 
-    $login = getlogin || (getpwuid($<))[0] || "Kilroy";
+    $login = getlogin || getpwuid($<) || "Kilroy";
 
 Do not consider getlogin() for authentication: it is not as
 secure as getpwuid().
@@ -1316,9 +1409,12 @@ Returns the socket option requested, or undefined if there is an error.
 
 =item glob EXPR
 
+=item glob
+
 Returns the value of EXPR with filename expansions such as a shell
 would do.  This is the internal function implementing the E<lt>*.*E<gt>
 operator, except it's easier to use.
+If EXPR is omitted, $_ is used.
 
 =item gmtime EXPR
 
@@ -1334,6 +1430,13 @@ 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.  If EXPR is omitted, does C<gmtime(time())>.
 
+In a scalar context, prints out the ctime(3) value:
+
+    $now_string = gmtime;  # e.g., "Thu Oct 13 04:54:34 1994"
+
+Also see the F<timegm.pl> library, and the strftime(3) function available
+via the POSIX module.
+
 =item goto LABEL
 
 =item goto EXPR
@@ -1343,8 +1446,9 @@ the range 0..6.  If EXPR is omitted, does C<gmtime(time())>.
 The goto-LABEL form finds the statement labeled with LABEL and resumes
 execution there.  It may not be used to go into any construct that
 requires initialization, such as a subroutine or a foreach loop.  It
-also can't be used to go into a construct that is optimized away.  It
-can be used to go almost anywhere else within the dynamic scope,
+also can't be used to go into a construct that is optimized away,
+or to get out of a block or subroutine given to sort().
+It can be used to go almost anywhere else within the dynamic scope,
 including out of subroutines, but it's usually better to use some other
 construct 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).
@@ -1547,7 +1651,7 @@ C<continue> block, if any, is not executed:
 
 Returns an lowercased version of EXPR.  This is the internal function
 implementing the \L escape in double-quoted strings.  
-Should respect any POSIX setlocale() settings.
+Respects current LC_CTYPE locale if C<use locale> in force.  See L<perllocale>.
 
 If EXPR is omitted, uses $_.
 
@@ -1557,7 +1661,7 @@ If EXPR is omitted, uses $_.
 
 Returns the value of EXPR with the first character lowercased.  This is
 the internal function implementing the \l escape in double-quoted strings.
-Should respect any POSIX setlocale() settings.
+Respects current LC_CTYPE locale if C<use locale> in force.  See L<perllocale>.
 
 If EXPR is omitted, uses $_.
 
@@ -1600,13 +1704,14 @@ follows:
 
 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.  If EXPR is omitted, does localtime(time).
+the range 0..6 and $year is year-1900, that is, $year is 123 in year
+2023.  If EXPR is omitted, uses the current time ("localtime(time)").
 
-In a scalar context, prints out the ctime(3) value:
+In a scalar context, returns the ctime(3) value:
 
     $now_string = localtime;  # e.g., "Thu Oct 13 04:54:34 1994"
 
-Also see the F<timelocal.pl> library, and the strftime(3) function available
+Also see the Time::Local module, and the strftime(3) function available
 via the POSIX module.
 
 =item log EXPR
@@ -1754,8 +1859,9 @@ If the filename begins with "|", the filename is interpreted as a command
 to which output is to be piped, and if the filename ends with a "|", the
 filename is interpreted See L<perlipc/"Using open() for IPC"> for more
 examples of this.  as command which pipes input to us.  (You may not have
-a raw open() to a command that pipes both in I<and> out, but see L<IPC::Open2>,
-L<IPC::Open3>, and L<perlipc/"Bidirectional Communication"> for alternatives.)
+a raw open() to a command that pipes both in I<and> out, but see
+L<IPC::Open2>, L<IPC::Open3>, and L<perlipc/"Bidirectional Communication">
+for alternatives.)
 
 Opening '-' opens STDIN and opening 'E<gt>-' opens STDOUT.  Open returns
 non-zero upon success, the undefined value otherwise.  If the open
@@ -1905,7 +2011,7 @@ If you want a "real" C open() (see L<open(2)> on your system), then
 you should use the sysopen() function.  This is another way to
 protect your filenames from interpretation.  For example:
 
-    use FileHandle;
+    use IO::Handle;
     sysopen(HANDLE, $path, O_RDWR|O_CREAT|O_EXCL, 0700)
        or die "sysopen $path: $!";
     HANDLE->autoflush(1);
@@ -2057,6 +2163,8 @@ for examples of such things.
 
 =item pop ARRAY
 
+=item pop 
+
 Pops and returns the last value of the array, shortening the array by
 1.  Has a similar effect to
 
@@ -2073,7 +2181,9 @@ like shift().
 
 Returns the offset of where the last C<m//g> search left off for the variable
 is in question ($_ is used when the variable is not specified). May be
-modified to change that offset.
+modified to change that offset.  Such modification will also influence
+the C<\G> zero-width assertion in regular expressions.  See L<perlre> and
+L<perlop>.
 
 =item print FILEHANDLE LIST
 
@@ -2108,8 +2218,14 @@ you will have to use a block returning its value instead:
 
 =item printf FORMAT, LIST
 
-Equivalent to a "print FILEHANDLE sprintf(FORMAT, LIST)".  The first argument
-of the list will be interpreted as the printf format.
+Equivalent to C<print FILEHANDLE sprintf(FORMAT, LIST)>.  The first argument
+of the list will be interpreted as the printf format.  If C<use locale> is
+in effect, the character used for the decimal point in formatted real numbers
+is affected by the LC_NUMERIC locale.  See L<perllocale>.
+
+Don't fall into the trap of using a printf() when a simple
+print() would do.  The print() is more efficient, and less
+error prone.
 
 =item prototype FUNCTION
 
@@ -2143,8 +2259,11 @@ Generalized quotes.  See L<perlop>.
 
 =item quotemeta 
 
-Returns the value of EXPR with with all regular expression
-metacharacters backslashed.  This is the internal function implementing
+Returns the value of EXPR with with all non-alphanumeric
+characters backslashed.  (That is, all characters not matching
+C</[A-Za-z_0-9]/> will be preceded by a backslash in the
+returned string, regardless of any locale settings.)
+This is the internal function implementing
 the \Q escape in double-quoted strings.
 
 If EXPR is omitted, uses $_.
@@ -2463,7 +2582,7 @@ actual filehandle.  Thus:
 Some programmers may prefer to think of filehandles as objects with
 methods, preferring to write the last example as:
 
-    use FileHandle;
+    use IO::Handle;
     STDERR->autoflush(1);
 
 =item select RBITS,WBITS,EBITS,TIMEOUT
@@ -2619,6 +2738,11 @@ has the same interpretation as in the system call of the same name.
 Returns the sine of EXPR (expressed in radians).  If EXPR is omitted,
 returns sine of $_.
 
+For the inverse sine operation, you may use the POSIX::sin()
+function, or use this relation:
+
+    sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) }
+
 =item sleep EXPR
 
 =item sleep
@@ -2676,6 +2800,12 @@ the subroutine not via @_ but as the package global variables $a and
 $b (see example below).  They are passed by reference, so don't
 modify $a and $b.  And don't try to declare them as lexicals either.
 
+You also cannot exit out of the sort block or subroutine using any of the
+loop control operators described in L<perlsyn> or with goto().
+
+When C<use locale> is in effect, C<sort LIST> sorts LIST according to the
+current collation locale.  See L<perllocale>.
+
 Examples:
 
     # sort lexically
@@ -2890,7 +3020,10 @@ Returns a string formatted by the usual printf conventions of the C
 language.  See L<sprintf(3)> or L<printf(3)> on your system for details.
 (The * character for an indirectly specified length is not
 supported, but you can get the same effect by interpolating a variable
-into the pattern.)  Some C libraries' implementations of sprintf() can
+into the pattern.)  If C<use locale> is
+in effect, the character used for the decimal point in formatted real numbers
+is affected by the LC_NUMERIC locale.  See L<perllocale>.
+Some C libraries' implementations of sprintf() can
 dump core when fed ludicrous arguments.
 
 =item sqrt EXPR
@@ -2904,11 +3037,36 @@ root of $_.
 
 Sets the random number seed for the C<rand> operator.  If EXPR is omitted,
 uses a semi-random value based on the current time and process ID, among
-other things.  Of course, you'd need something much more random than that for
-cryptographic purposes, because it's easy to guess the current time.
-Checksumming the compressed output of rapidly changing operating system
-status programs is the usual method.  Examples are posted regularly to
-the comp.security.unix newsgroup.
+other things.  In versions of Perl prior to 5.004 the default seed was
+just the current time().  This isn't a particularly good seed, so many
+old programs supply their own seed value (often C<time ^ $$> or C<time ^
+($$ + ($$ << 15))>), but that isn't necessary any more.
+
+You need something much more random than the default seed for
+cryptographic purposes, though.  Checksumming the compressed output of
+one or more rapidly changing operating system status programs is the
+usual method. For example:
+
+    srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
+
+If you're particularly concerned with this, see the Math::TrulyRandom
+module in CPAN.
+
+Do I<not> call srand() multiple times in your program unless you know
+exactly what you're doing and why you're doing it.  The point of the
+function is to "seed" the rand() function so that rand() can produce
+a different sequence each time you run your program.  Just do it once at the
+top of your program, or you I<won't> get random numbers out of rand()!
+
+Frequently called programs (like CGI scripts) that simply use 
+
+    time ^ $$
+
+for a seed can fall prey to the mathematical property that 
+
+    a^b == (a+1)^(b+1)
+
+one-third of the time.  So don't do that.
 
 =item stat FILEHANDLE
 
@@ -2939,7 +3097,7 @@ meaning of the fields:
   size     total size of file, in bytes 
   atime            last access time since the epoch
   mtime            last modify time since the epoch
-  ctime            inode change time (NOT creation type!) since the epoch
+  ctime            inode change time (NOT creation time!) since the epoch
   blksize   preferred block size for file system I/O
   blocks    actual number of blocks allocated
 
@@ -3092,6 +3250,9 @@ the value of PERMS specifies the permissions of the newly created
 file.  If PERMS is omitted, the default value is 0666, which allows
 read and write for all.  This default is reasonable: see C<umask>.
 
+The IO::File module provides a more object-oriented approach, if you're
+into that kind of thing.
+
 =item sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
 
 =item sysread FILEHANDLE,SCALAR,LENGTH
@@ -3118,8 +3279,41 @@ Note that argument processing varies depending on the number of
 arguments.  The return value is the exit status of the program as
 returned by the wait() call.  To get the actual exit value divide by
 256.  See also L</exec>.  This is I<NOT> what you want to use to capture 
-the output from a command, for that you should use merely back-ticks, as
-described in L<perlop/"`STRING`">.
+the output from a command, for that you should use merely back-ticks or
+qx//, as described in L<perlop/"`STRING`">.
+
+Because system() and back-ticks block SIGINT and SIGQUIT, killing the
+program they're running doesn't actually interrupt your program.
+
+    @args = ("command", "arg1", "arg2");
+    system(@args) == 0 
+        or die "system @args failed: $?" 
+
+Here's a more elaborate example of analysing the return value from
+system() on a UNIX system to check for all possibilities, including for
+signals and coredumps.
+
+    $rc = 0xffff & system @args;
+    printf "system(%s) returned %#04x: ", "@args", $rc;
+    if ($rc == 0) {
+       print "ran with normal exit\n";
+    } 
+    elsif ($rc == 0xff00) {
+       print "command failed: $!\n";
+    } 
+    elsif ($rc > 0x80) {
+       $rc >>= 8;
+       print "ran with non-zero exit status $rc\n";
+    } 
+    else {
+       print "ran with ";
+       if ($rc &   0x80) {
+           $rc &= ~0x80;
+           print "coredump from ";
+       } 
+       print "signal $rc\n"
+    } 
+    $ok = ($rc != 0);
 
 =item syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
 
@@ -3245,7 +3439,7 @@ on your system.
 
 Returns an uppercased version of EXPR.  This is the internal function
 implementing the \U escape in double-quoted strings.
-Should respect any POSIX setlocale() settings.
+Respects current LC_CTYPE locale if C<use locale> in force.  See L<perllocale>.
 
 If EXPR is omitted, uses $_.
 
@@ -3255,7 +3449,7 @@ If EXPR is omitted, uses $_.
 
 Returns the value of EXPR with the first character uppercased.  This is
 the internal function implementing the \u escape in double-quoted strings.
-Should respect any POSIX setlocale() settings.
+Respects current LC_CTYPE locale if C<use locale> in force.  See L<perllocale>.
 
 If EXPR is omitted, uses $_.
 
@@ -3394,8 +3588,11 @@ That is exactly equivalent to
     BEGIN { require Module; }
 
 If the VERSION argument is present between Module and LIST, then the
-C<use> will fail if the C<$VERSION> variable in package Module is
-less than VERSION.
+C<use> will call the VERSION method in class Module with the given
+version as an argument.  The default VERSION method, inherited from
+the Universal class, croaks if the given version is larger than the
+value of the variable $Module::VERSION.  (Note that there is not a
+comma after VERSION!)
 
 Because this is a wide-open interface, pragmas (compiler directives)
 are also implemented this way.  Currently implemented pragmas are:
@@ -3495,8 +3692,38 @@ for a scalar.
 
 =item warn LIST
 
-Produces a message on STDERR just like die(), but doesn't exit or
-on an exception.
+Produces a message on STDERR just like die(), but doesn't exit or throw
+an exception.
+
+No message is printed if there is a C<$SIG{__WARN__}> handler
+installed.  It is the handler's responsibility to deal with the message
+as it sees fit (like, for instance, converting it into a die()).  Most
+handlers must therefore make arrangements to actually display the
+warnings that they are not prepared to deal with, by calling warn()
+again in the handler.  Note that this is quite safe and will not
+produce an endless loop, since C<__WARN__> hooks are not called from
+inside one.
+
+You will find this behavior is slightly different from that of
+C<$SIG{__DIE__}> handlers (which don't suppress the error text, but can
+instead call die() again to change it).
+
+Using a C<__WARN__> handler provides a powerful way to silence all
+warnings (even the so-called mandatory ones).  An example:
+
+    # wipe out *all* compile-time warnings
+    BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
+    my $foo = 10;
+    my $foo = 20;          # no warning about duplicate my $foo,
+                           # but hey, you asked for it!
+    # no compile-time or run-time warnings before here
+    $DOWARN = 1;
+
+    # run-time warnings enabled after here
+    warn "\$foo is alive and $foo!";     # does show up
+
+See L<perlvar> for details on setting C<%SIG> entries, and for more
+examples.
 
 =item write FILEHANDLE