# or using a slice (might be more efficient, but doesn't read as nicely) sub hash_slice { my ($hr, @k) = @_; my %ret; @ret{@k} = @$hr{@k}; return %ret; }