Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to loop through hash of array and convert into hash with key and value.

by NetWallah (Canon)
on Dec 28, 2019 at 02:33 UTC ( [id://11110681]=note: print w/replies, xml ) Need Help??


in reply to How to loop through hash of array and convert into hash with key and value.

Verified working code:
$VAR1 = { map { $_->{name} => $_ } @$VAR1 };
Don't be shy about asking specific, detailed questions on how/why that works, after researching the "map" function.

                "From there to here, from here to there, funny things are everywhere." -- Dr. Seuss

  • Comment on Re: How to loop through hash of array and convert into hash with key and value.
  • Download Code

Replies are listed 'Best First'.
Re^2: How to loop through hash of array and convert into hash with key and value.
by Sami_R (Sexton) on Dec 28, 2019 at 11:11 UTC
    Mapping worked after modifying like...
    my $VAR3 = { map { delete $_->{name} => $_ } @$VAR1 };
    Thanks.
Re^2: How to loop through hash of array and convert into hash with key and value.
by stevieb (Canon) on Dec 28, 2019 at 02:42 UTC

    Unfortunately, this doesn't address removing the name from the inner hash references.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110681]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found