Say I have a hash that I can index as:
$hash{$document}{$word}
From what I read online (although I could not find this on perlreftut, perldsc or perllol), I can slice a hash using a list if I use the @ prefix on my hash to indicate that I want the hash to return a list. However, if I try to slice my hash using a list @list:
@%hash{$document}{@list}
I get several "Scalar values ... better written" errors.
How can I slash a nested hash in Perl?
The sigill for your hash must be
@, like so:Assuming
@listcontains valid keys for%hashit will return the corresponding values, orundefif the key does not exist.This is based on the general rule of a hash slice: