Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Turning Hash of Arrayrefs into Hash of Hashrefs

by merlyn (Sage)
on Jun 13, 2000 at 04:33 UTC ( #17824=note: print w/replies, xml ) Need Help??


in reply to clarification...
in thread hash of lists - hash of hashes

In place, you could do something like this:
for (@HoL{keys %HoL}) { $_ = {map {$_, 1} @$_}; }
(You can use values in place of the slice in 5.6, but I'm not there yet.)

If you really need a copy, that's a little odder, like this:

%HoH = map { $_ => {map { $_, 1 } @{$HoL{$_}}} } keys %HoL;
Untested, but I think I got my indirections right.

-- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://17824]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2016-12-03 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.