How to retrieve the values of required keys in Perl [closed]

To get a list of the values for many keys at once, use a hash slice:

@lots_of_values = @hash{ @lots_of_keys };

Because a list is the result, you use the @ sigil even though it is a hash; the values will be the order of the keys specified, including undef values where the specified keys don’t exist in the hash.

Leave a Comment