Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Keep It Simple, Stupid
 
PerlMonks  

Re: accessing elements in array of hashes

by johngg (Abbot)
on Jun 27, 2013 at 19:18 UTC ( #1041081=note: print w/ replies, xml ) Need Help??


in reply to accessing elements in array of hashes

The core Data::Dumper module is an extremely useful tool when trying to work out whether your data structures have turned out as you intended.

$ perl -Mstrict -Mwarnings -MData::Dumper -E ' my %h1 = ( a => 1, b => 2 ); my %h2 = ( z => 26, y => 25 ); my @badAoH; push @badAoH, %h1; push @badAoH, %h2; print Data::Dumper->Dumpxs( [ \ @badAoH ], [ qw{ *badAoH } ] ); my @goodAoH; push @goodAoH, \ %h1; push @goodAoH, \ %h2; print Data::Dumper->Dumpxs( [ \ @goodAoH ], [ qw{ *goodAoH } ] );' @badAoH = ( 'a', 1, 'b', 2, 'y', 25, 'z', 26 ); @goodAoH = ( { 'a' => 1, 'b' => 2 }, { 'y' => 25, 'z' => 26 } ); $

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: accessing elements in array of hashes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-04-21 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls