X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlsub.pod;h=5ecd346a14e1f9d1cfc551049762fb740056e01b;hb=ca06c01c30b19d0094642f2e317dadf13d4509cd;hp=7a51e5cabb984836e37806f462181013d9fa0ca5;hpb=ba1f8e91c84952b3b5031787643c5e7b0bfa1fa8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 7a51e5c..5ecd346 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -227,10 +227,10 @@ indirectly by the run-time system itself, usually due to a triggered event. Subroutines that do special, pre-defined things include C, C, C plus all functions mentioned in L and L. -The C, C, C and C subroutines are not so much -subroutines as named special code blocks, of which you can have more -than one in a package, and which you can B call explicitly. See -L +The C, C, C, C and C subroutines +are not so much subroutines as named special code blocks, of which you +can have more than one in a package, and which you can B call +explicitly. See L =head2 Private Variables via my() X X X X X @@ -521,8 +521,9 @@ starts to run: } } -See L about the -special triggered code blocks, C, C, C and C. +See L about the +special triggered code blocks, C, C, C, +C and C. If declared at the outermost scope (the file scope), then lexicals work somewhat like C's file statics. They are available to all @@ -1054,7 +1055,7 @@ corresponding built-in. sub myopen (*;$) myopen HANDLE, $name sub mypipe (**) mypipe READHANDLE, WRITEHANDLE sub mygrep (&@) mygrep { /foo/ } $a, $b, $c - sub myrand ($) myrand 42 + sub myrand (;$) myrand 42 sub mytime () mytime Any backslashed prototype character represents an actual argument @@ -1098,9 +1099,13 @@ follows: ... } -A semicolon separates mandatory arguments from optional arguments. +A semicolon (C<;>) separates mandatory arguments from optional arguments. It is redundant before C<@> or C<%>, which gobble up everything else. +As the last character of a prototype, or just before a semicolon, you can +use C<_> in place of C<$>: if this argument is not provided, C<$_> will be +used instead. + Note how the last three examples in the table above are treated specially by the parser. C is parsed as a true list operator, C is parsed as a true unary operator with unary @@ -1367,7 +1372,8 @@ And, as you'll have noticed from the previous example, if you override C, the C<< <*> >> glob operator is overridden as well. In a similar fashion, overriding the C function also overrides -the equivalent I/O operator C<< >>. +the equivalent I/O operator C<< >>. Also, overriding +C also overrides the operators C<``> and C. Finally, some built-ins (e.g. C or C) can't be overridden.