Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: can we pass two variable to foreach loop

by bobf (Monsignor)
on Mar 28, 2007 at 05:45 UTC ( #606915=note: print w/ replies, xml ) Need Help??


in reply to can we pass two variable to foreach loop

No, but you can use a list of references to hashes or arrays that contain multiple values:

my @AoH = ( { firstname => 'foo', lastname => 'bar' }, { firstname => 'baz', lastname => 'quux' } ); foreach my $href ( @AoH ) { # do something with $href->{firstname} and $href->{lastname} }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2016-06-30 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (391 votes). Check out past polls.