Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

(jeffa) Re: foreach keys over multiple hashes

by jeffa (Bishop)
on Jun 19, 2002 at 20:18 UTC ( [id://175835]=note: print w/replies, xml ) Need Help??


in reply to foreach keys over multiple hashes

By using references:
use strict; my %one; my %two; my %three; my $hashes = [\%one, \%two, \%three]; for (@$hashes) { for my $k (keys %$_) { #do something } }
UPDATE: storing them in an array reference is not necessary, i just wanted to show how to do so. :) But you do have to store the hashes as reference or else they will 'flatten' into the array that contains them.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found