When we evaluate a hash in a list context, Perl gives us the paired list
that can be very useful. However, sometimes we may only want to look at
the list of keys, or the list of values. Perl provides two optimized
functions for doing this: keys
and values
.
use strict; my %table = qw/schmoe joe smith john simpson bart/; my @lastNames = keys %table; # @lastNames is: qw/schmoe smith simpson/ my @firstNames = values %table; # @firstNames is: qw/joe john bart/