X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlfunc.pod;h=65e019bf0641a962a2f624f9d86d776651854378;hb=3c20a832e0afaa3d5dac4e9889c4ce2f06a128c5;hp=840ddbcc00aa8fe048a221e13dfe9e4ebcd7efc5;hpb=b48653af3d8bbfd0f502d07871e8cbfb4c62dd6c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 840ddbc..65e019b 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -525,7 +525,7 @@ like for example images. If LAYER is present it is a single string, but may contain multiple directives. The directives alter the behaviour of the file handle. -When LAYER is present using binmode on text file makes sense. +When LAYER is present using binmode on a text file makes sense. If LAYER is omitted or specified as C<:raw> the filehandle is made suitable for passing binary data. This includes turning off possible CRLF @@ -1549,7 +1549,8 @@ itself. See L for more on how the evaluation context can be determined. If there is a syntax error or runtime error, or a C statement is -executed, an undefined value is returned by C, and C<$@> is set to the +executed, C returns an undefined value in scalar context +or an empty list in list context, and C<$@> is set to the error message. If there was no error, C<$@> is guaranteed to be a null string. Beware that using C neither silences perl from printing warnings to STDERR, nor does it stuff the text of warning messages into C<$@>. @@ -1735,8 +1736,7 @@ X X Given an expression that specifies a hash element or array element, returns true if the specified element in the hash or array has ever -been initialized, even if the corresponding value is undefined. The -element is not autovivified if it doesn't exist. +been initialized, even if the corresponding value is undefined. print "Exists\n" if exists $hash{$key}; print "Defined\n" if defined $hash{$key}; @@ -1936,25 +1936,27 @@ perl. Here's a mailbox appender for BSD systems. - use Fcntl ':flock'; # import LOCK_* constants + use Fcntl qw(:flock SEEK_END); # import LOCK_* and SEEK_END constants sub lock { - flock(MBOX,LOCK_EX); - # and, in case someone appended - # while we were waiting... - seek(MBOX, 0, 2); + my ($fh) = @_; + flock($fh, LOCK_EX) or die "Cannot lock mailbox - $!\n"; + + # and, in case someone appended while we were waiting... + seek($fh, 0, SEEK_END) or die "Cannot seek - $!\n"; } sub unlock { - flock(MBOX,LOCK_UN); + my ($fh) = @_; + flock($fh, LOCK_UN) or die "Cannot unlock mailbox - $!\n"; } open(my $mbox, ">>", "/usr/spool/mail/$ENV{'USER'}") or die "Can't open mailbox: $!"; - lock(); + lock($mbox); print $mbox $msg,"\n\n"; - unlock(); + unlock($mbox); On systems that support a real flock(), locks are inherited across fork() calls, whereas those that must resort to the more capricious fcntl() @@ -2348,8 +2350,14 @@ implementing the C<< <*.c> >> operator, but you can use it directly. If EXPR is omitted, C<$_> is used. The C<< <*.c> >> operator is discussed in more detail in L. +Note that C will split its arguments on whitespace, treating +each segment as separate pattern. As such, C would +match all files with a F<.c> or F<.h> extension. The expression +C would match all files in the current working directory. + Beginning with v5.6.0, this operator is implemented using the standard -C extension. See L for details. +C extension. See L for details, including +C which does not treat whitespace as a pattern separator. =item gmtime EXPR X X X @@ -2848,7 +2856,7 @@ If EXPR is omitted, stats C<$_>. =item m// -The match operator. See L. +The match operator. See L. =item map BLOCK LIST X @@ -4769,7 +4777,7 @@ the C function of the L module. =item s/// -The substitution operator. See L. +The substitution operator. See L. =item say FILEHANDLE LIST X @@ -5514,7 +5522,7 @@ produces the list value If you had the entire header of a normal Unix email message in $header, you could split it up into fields and their values this way: - $header =~ s/\n\s+/ /g; # fix continuation lines + $header =~ s/\n(?=\s)//g; # fix continuation lines %hdrs = (UNIX_FROM => split /^(\S*?):\s*/m, $header); The pattern C may be replaced with an expression to specify @@ -6667,7 +6675,8 @@ Note that times for children are included only after they terminate. =item tr/// -The transliteration operator. Same as C. See L. +The transliteration operator. Same as C. See +L. =item truncate FILEHANDLE,LENGTH X @@ -7425,6 +7434,7 @@ Note that write is I the opposite of C. Unfortunately. =item y/// -The transliteration operator. Same as C. See L. +The transliteration operator. Same as C. See +L. =back