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

Re: Array of Hashes in subroutines.

by biohisham (Priest)
on Sep 19, 2010 at 07:17 UTC ( [id://860671]=note: print w/replies, xml ) Need Help??


in reply to Array of Hashes in subroutines.

In the context of your code, @ref01 is better written as $ref01.

You can make use of the flexibility of referencing and dereferencing to re-write

foreach $i (sort keys (%{$ref01[0]})) { print "$i: ${$ref01[0]}{$i} ${$ref01[1]}{$i} ${$ref01[2]}{$i}\n"; }
in a briefer and yet robust way. you don't want to index a hundred-element array manually now, do you?
foreach $i (sort keys (%{$ref01})) { print "$i: @{$ref01->{$i}}\n"; }
An interesting documentation page is perlcheat at http://perldoc.perl.org. You can access the same from your command console, type perldoc perlcheat.

Best of luck and have a nice perl journey ..

Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2025-02-12 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found