Online Programming Reference Guides - Perl
[an error occurred while processing this directive]
Contents
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
[an error occurred while processing this directive]

5.5 Slices

It turns out you can slice hashes just like you were able to slice arrays. This can be useful if you need to extract a certain set of values out of a hash into a list.

use strict; my %table = qw/schmoe joe smith john simpson bart/; my @friends = @table{'schmoe', 'smith'}; # @friends has qw/joe john/

Note the use of the @ in front of the hash name. This shows that we are indeed producing a normal list, and you can use this construct in any list context you would like.





[an error occurred while processing this directive]