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.......