hashsubsetraku

copy some hash elements to another hash


Is there a more idiomatic way to create a hash with a sub-set of keys from another hash.

Currently I have:

a-subroutine('param',
  %(:$level, 
    :id(%prm<id>), :target(%prm<target>), 
    :caption(%prm<caption>), :delta(%prm<delta>)
   )
)

%prm has more keys than needed for the new hash argument.

The repeated key / %prm<key> seems ugly.


Solution

  • You could use

    %(:$level, slip %prm<id target caption delta>:p)