Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 pondering the Monastery: (14)
As of 2015-07-06 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (80 votes), past polls