Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 about the Monastery: (13)
As of 2015-07-31 19:37 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 (280 votes), past polls