Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Slicing multilevel hashes

by Roy Johnson (Monsignor)
on Apr 07, 2005 at 17:33 UTC ( #445808=note: print w/replies, xml ) Need Help??

in reply to Slicing multilevel hashes

A slice -- even a hash slice -- is not a hash. It's a list (that includes only the values components, not the keys). That's why the sigil is @ and not %. You cannot hash-dereference a list. As dragonchild astutely suggested, you can use map to get the effect you want.
map @{$_}{@keys}, @hoh{@keys};

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Slicing multilevel hashes
by bobf (Monsignor) on Apr 07, 2005 at 18:57 UTC

    Thanks for the speedy replies. I did use map to get a working solution (map{ $_->{d} } @hoh{@keys}) but I thought there might be another way to do it (thanks for the example). In the back of my mind I didn't think the @hoh{@keys}{d} idea was possible, but if it was then if anyone would know how to do it, it would be someone at Perl Monks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://445808]
[1nickt]: Brethren, I just noticed in the CPAN ticker Retry, which led me to Attempt, by Mark Fowler. Does anyone have experience with either of these utilities?
[Corion]: No. Back when I toyed with the idea, I found that writing the loop explicitly was usually less code than passing the configuration+ callback to the retrier...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-05-24 12:34 GMT
Find Nodes?
    Voting Booth?