X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/b208c909347c1ee277714eaa1bda5a4e0d85a64e..aa80e1dcb371c94af142cbd5b35b014104f03584:/pod/perldata.pod diff --git a/pod/perldata.pod b/pod/perldata.pod index a79ca65..03191b5 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -668,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: @@ -692,15 +693,12 @@ are used. For example: print "Darwin's First Name is ", $scientists{"Darwin"}, "\n"; -=head2 Slices -X X X +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 X X A slice accesses several elements of a list, an array, or a hash simultaneously using a list of subscripts. It's more convenient