Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041081]
help
Chatterbox?
[marto]: I think that actually caught up with me yesterday, felt a really sharp pain where my neck meets my skull.
[Corion]: marto: Ouch, yeah...
[marto]: the boys uncle will take them for a couple of hours this afternoon :)
[marto]: only at work 3 days this week, then off to Copenhagen for a wedding
[marto]: back the following Monday, potentially gone 2-3 days the next week for work

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-11-19 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (280 votes). Check out past polls.

    Notices?