Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Dereference an Array of Hashes

by kennethk (Abbot)
on Apr 25, 2012 at 16:22 UTC ( #967110=note: print w/ replies, xml ) Need Help??


in reply to Dereference an Array of Hashes

While your code snippet could use some more context, I think your issue is that the outer for loop of your output is looking at @managers but your assignment is using %managers. You should get your expected result with

push( @{$managers{$mgr}}, $sub_tot_upd_by_mgr); push( @{$managers{$mgr}}, $sub_tot_events_by_mgr); for my $t ( keys %managers ) { for my $b (0 .. $#{$managers{$t}}) { print "$t and $b is $managers{$t}[$b]\n"; } }

This type of variable confusion could be quickly diagnosed with strict; see Use strict warnings and diagnostics or die. Also note $b is a special variable in the context of sort, and should generally be avoided for normal usage; see $b.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: Dereference an Array of Hashes
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2015-07-06 15:28 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 (77 votes), past polls