Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: When would you choose foreach instead of map?

by dvergin (Monsignor)
on May 20, 2004 at 20:06 UTC ( #355059=note: print w/ replies, xml ) Need Help??


in reply to When would you choose foreach instead of map?

And of course if you wanted to alter the array in place (not creating a new one) and also wanted to do it in one succinct line (as your map does), you could just say:

$_ *= 2 for @array;

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall


Comment on Re: When would you choose foreach instead of map?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2015-07-28 21:11 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 (259 votes), past polls