Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Converting HoA into HoH

by BrowserUk (Pope)
on Oct 31, 2005 at 06:19 UTC ( #504167=note: print w/replies, xml ) Need Help??

in reply to Converting HoA into AoH

Ths assumes that each array has an even number of elements.

my $HoH = { map{ $_ => { @{ $HoA->{$_} } } } keys %{ $HoA } };

Update: I completely misread that. Here's the correct version.

my $HoH = { map{ $_ => { map{ $_ => } @{ $HoA->{$_} } } } keys %{ $Ho +A } };

Update2: And still it was wrong. I think you have your answer now, so I'll shut up.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Converting HoA into HoH
by neversaint (Deacon) on Oct 31, 2005 at 06:26 UTC
    Dear BrowserUk,
    Thanks a lot for the response. But your code above returns this only:
    $VAR1 = { 'flintstones' => { 'fred' => 'barney' }, 'jetsons' => { 'george' => 'jane' } };
    Please correct me if I'm wrong. And also the size of the array may not be even.

    neversaint and everlastingly indebted.......

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2020-06-02 10:44 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (17 votes). Check out past polls.