Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: can we pass two variable to foreach loop

by BrowserUk (Pope)
on Mar 28, 2007 at 05:43 UTC ( #606914=note: print w/replies, xml ) Need Help??


in reply to can we pass two variable to foreach loop

No. Not in perl 5. But you could do

foreach my $ref ( [ $name, $lastname ] ) { my( $x, $y ) = @$ref; # do something }

Whether that is applicable to your problem would require more context. Where do the values you which to index in pairs come from?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: can we pass two variable to foreach loop
by Anonymous Monk on Mar 22, 2011 at 05:18 UTC
    what does @$listname stand for?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://606914]
help
Chatterbox?
[holli]: i am designing an interface. check this out, can you tell immediatly tell me what the code does?
[holli]: scratch one "tell". you decide which ;)

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2017-09-26 21:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (297 votes). Check out past polls.

    Notices?