In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/aa80e1dcb371c94af142cbd5b35b014104f03584?hp=39ac3336da840fc340d83005a1b728db40a469ef>
- Log ----------------------------------------------------------------- commit aa80e1dcb371c94af142cbd5b35b014104f03584 Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 14:01:55 2011 -0800 perldata: remove duplicate text from adjacent sections M pod/perldata.pod commit b208c909347c1ee277714eaa1bda5a4e0d85a64e Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 13:46:47 2011 -0800 perlfunc/eval: $@ is now set after unwinding M pod/perlfunc.pod commit 82bcec1beafdddf442ea155a666fc0b0dce8fe5f Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 13:43:38 2011 -0800 perlfunc: hyphenate a compound adjective M pod/perlfunc.pod commit e2b457c0a2a1b829d40d2ab9e84c76fa3641aaba Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 13:36:58 2011 -0800 perldata: retitle a section The âArray Joining Delimiterâ section is about array interpolation in general, not just the $" variable. M pod/perldata.pod commit d411c85d23cd217cfd98d1fa22f96554128fafb5 Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 13:32:15 2011 -0800 perldelta: âpackage;â is no longer supported M pod/perldata.pod commit 3921068cd7e1dda8edfb21394694f0f4f426234e Author: Father Chrysostomos <[email protected]> Date: Fri Feb 11 12:48:23 2011 -0800 perldata tweaks M pod/perldata.pod ----------------------------------------------------------------------- Summary of changes: pod/perldata.pod | 25 ++++++++++++------------- pod/perlfunc.pod | 8 ++++---- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pod/perldata.pod b/pod/perldata.pod index 98663c4..03191b5 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -52,7 +52,7 @@ X<scalar> $#days # the last index of array @days Entire arrays (and slices of arrays and hashes) are denoted by '@', -which works much like the word "these" or "those" does in English, +which works much as the word "these" or "those" does in English, in that it indicates multiple values are expected. X<array> @@ -140,7 +140,7 @@ to determine the context for the right argument. Assignment to a scalar evaluates the right-hand side in scalar context, while assignment to an array or hash evaluates the righthand side in list context. Assignment to a list (or slice, which is just a list -anyway) also evaluates the righthand side in list context. +anyway) also evaluates the right-hand side in list context. When you use the C<use warnings> pragma or Perl's B<-w> command-line option, you may see warnings @@ -391,7 +391,7 @@ inet_aton()/inet_ntoa() routines of the Socket package. Note that since Perl 5.8.1 the single-number v-strings (like C<v65>) are not v-strings before the C<< => >> operator (which is usually used -to separate a hash key from a hash value), instead they are interpreted +to separate a hash key from a hash value); instead they are interpreted as literal strings ('v65'). They were v-strings from Perl 5.6.0 to Perl 5.8.0, but that caused more confusion and breakage than good. Multi-number v-strings like C<v65.66> and C<65.66.67> continue to @@ -406,7 +406,8 @@ represent the current filename, 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 C<package;> directive), __PACKAGE__ is the undefined -value. +value. (But the empty C<package;> is no longer supported, as of version +5.10.) X<__FILE__> X<__LINE__> X<__PACKAGE__> X<line> X<file> X<package> The two control characters ^D and ^Z, and the tokens __END__ and __DATA__ @@ -451,7 +452,7 @@ produces a compile-time error instead. The restriction lasts to the end of the enclosing block. An inner block may countermand this by saying C<no strict 'subs'>. -=head3 Array Joining Delimiter +=head3 Array Interpolation X<array, interpolation> X<interpolation, array> X<$"> Arrays and slices are interpolated into double-quoted strings @@ -667,7 +668,8 @@ of how to arrange for an output ordering. =head2 Subscripts -An array is subscripted by specifying a dollar sign (C<$>), then the +An array can be accessed one scalar at a +time by specifying a dollar sign (C<$>), then the name of the array (without the leading C<@>), then the subscript inside square brackets. For example: @@ -691,15 +693,12 @@ are used. For example: print "Darwin's First Name is ", $scientists{"Darwin"}, "\n"; -=head2 Slices -X<slice> X<array, slice> X<hash, slice> +You can also subscript a list to get a single element from it: -A common way to access an array or a hash is one scalar element at a -time. You can also subscript a list to get a single element from it. + $dir = (getpwnam("daemon"))[7]; - $whoami = $ENV{"USER"}; # one element from the hash - $parent = $ISA[0]; # one element from the array - $dir = (getpwnam("daemon"))[7]; # likewise, but with list +=head2 Slices +X<slice> X<array, slice> X<hash, slice> A slice accesses several elements of a list, an array, or a hash simultaneously using a list of subscripts. It's more convenient diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index ec265b1..ece1005 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1605,7 +1605,7 @@ See L</warn>, L<perlvar>, L<warnings> and L<perllexwarn>. Note that, because C<eval> traps otherwise-fatal errors, it is useful for determining whether a particular feature (such as C<socket> or C<symlink>) -is implemented. It is also Perl's exception trapping mechanism, where +is implemented. It is also Perl's exception-trapping mechanism, where the die operator is used to raise exceptions. If you want to trap errors when loading an XS module, some problems with @@ -1676,8 +1676,8 @@ normally you I<would> like to use double quotes, except that in this particular situation, you can just use symbolic references instead, as in case 6. -The assignment to C<$@> occurs before restoration of localised variables, -which means a temporary is required if you want to mask some but not all +Before Perl 5.14, the assignment to C<$@> occured before restoration of localised variables, which means that, if your code is to run on older +versions, a temporary is required if you want to mask some but not all errors: # alter $@ on nefarious repugnancy only @@ -1686,7 +1686,7 @@ errors: { local $@; # protect existing $@ eval { test_repugnancy() }; - # $@ =~ /nefarious/ and die $@; # DOES NOT WORK + # $@ =~ /nefarious/ and die $@; # Perl 5.14 and higher only $@ =~ /nefarious/ and $e = $@; } die $e if defined $e -- Perl5 Master Repository
