diff options
author | Aristotle Pagaltzis <pagaltzis@gmx.de> | 2012-08-31 08:45:37 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-31 08:48:03 -0700 |
commit | f51152efb95ba4281387bc22b0734fb4c3ed3ad1 (patch) | |
tree | d26541ad8dae40ba31b079ea264d86bd251b7c65 /pod/perldata.pod | |
parent | a121486f21cdcf787b2bd623a1efdfd371768e0d (diff) | |
download | perl-f51152efb95ba4281387bc22b0734fb4c3ed3ad1.tar.gz |
[perl #114498] Document (0)[1,2] better
Diffstat (limited to 'pod/perldata.pod')
-rw-r--r-- | pod/perldata.pod | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod index 3a4776c550..9bff98f220 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -777,13 +777,18 @@ A slice of an empty list is still an empty list. Thus: @a = ()[1,0]; # @a has no elements @b = (@a)[0,1]; # @b has no elements - @c = (0,1)[2,3]; # @c has no elements But: @a = (1)[1,0]; # @a has two elements @b = (1,undef)[1,0,2]; # @b has three elements +More generally, a slice yields the empty list if it indexes only +beyond the end of a list: + + @a = (1)[ 1,2]; # @a has no elements + @b = (1)[0,1,2]; # @b has three elements + This makes it easy to write loops that terminate when a null list is returned: |