Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Converting HoA into AoH

by pg (Canon)
on Oct 31, 2005 at 06:25 UTC ( [id://504169]=note: print w/replies, xml ) Need Help??


in reply to Converting HoA into AoH

Hopefully you understand what that data structure means. It means that, at the top level, you are creating a hash ref with two pairs of elements, each with a hash ref as a key. My guess is that you are probably looking for:

[ { flinstones => "fred", jetsons => "george" }, { flinstones => "fred", jetsons => "jane" }, { flinstones => "barney", jetsons => "george" }, { flinstones => "barney", jetsons => "jane" }, ];

With your data strcture, try this code:

use Data::Dumper; use strict; use warnings; my $blah = { { flinstones => "fred", jetsons => "george" }, { flinstones => "fred", jetsons => "jane" }, { flinstones => "barney", jetsons => "george" }, { flinstones => "barney", jetsons => "jane" }, }; print Dumper($blah);

Which prints:

$VAR1 = { 'HASH(0x224ef8)' => { 'flinstones' => 'fred', 'jetsons' => 'jane' }, 'HASH(0x1876560)' => { 'flinstones' => 'barney', 'jetsons' => 'jane' } };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-19 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found