in reply to How to extract part of a hash

# use like this: %pets = hash_slice( \%hash, qw( dog cat ) );

For once, this may be a situation in which using a prototype would not be that bad:

sub hash_slice (\%@) { my $h=shift; map { $_ => $h->{$_} } @_; }

(Or the other way with slices. I don't really care.)