foreach and map..how are they different?

2007-08-24 Thread Dan Sopher
Aside from the syntax, is there a difference in the way 'map' and 'foreach' process? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: foreach and map..how are they different?

2007-08-24 Thread Randal L. Schwartz
Dan == Dan Sopher [EMAIL PROTECTED] writes: Dan Aside from the syntax, is there a difference in the way 'map' and Dan 'foreach' process? Yes. map is an expression. foreach is a statement. foreach can't be nested inside a larger expression. map is *meant* to do that, and using it in a void

Re: foreach and map..how are they different?

2007-08-24 Thread Paul Lalli
On Aug 24, 2:21 pm, [EMAIL PROTECTED] (Dan Sopher) wrote: Aside from the syntax, is there a difference in the way 'map' and 'foreach' process? foreach is just a loop. map returns values. Specifically, it returns the value of the BLOCK/EXPR for each iteration of the loop. my @doubles = map {

Re: foreach and map..how are they different?

2007-08-24 Thread Chas Owens
On 8/24/07, Dan Sopher [EMAIL PROTECTED] wrote: Aside from the syntax, is there a difference in the way 'map' and 'foreach' process? snip There are many differences, in addition to what has already been said map can be more or less cpu efficient than depending on the task*. If you can use map

Re: foreach and map..how are they different?

2007-08-24 Thread Rob Dixon
Dan Sopher wrote: Aside from the syntax, is there a difference in the way 'map' and 'foreach' process? Hi Dan Internally they're very similar, but you shouldn't be thinking like that. As Randal said, foreach is a statement - a language construct like 'if', 'while', 'else' and so on - while

Re: foreach and map..how are they different?

2007-08-24 Thread Jeff Pang
Both map and foreach can do the same thing,though they're used in different syntax environment. I follow a rule,if you need to return a result list,use map.Otherwise use for/foreach. Also sometime we can use map to do some flexible translation,like Schwartz Translation. 2007/8/25, Dan Sopher

Re: foreach and map..how are they different?

2007-08-24 Thread Randal L. Schwartz
Jeff == Jeff Pang [EMAIL PROTECTED] writes: Jeff Also sometime we can use map to do some flexible translation,like Jeff Schwartz Translation. That's a new one for me. Are you trying to say Schwartzian Transform? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Re: foreach and map..how are they different?

2007-08-24 Thread Jeff Pang
2007/8/25, Randal L. Schwartz [EMAIL PROTECTED]: Jeff == Jeff Pang [EMAIL PROTECTED] writes: Jeff Also sometime we can use map to do some flexible translation,like Jeff Schwartz Translation. That's a new one for me. Are you trying to say Schwartzian Transform? Yes,sorry for spelling