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