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 { $_ * 2 } @nums;

is exactly equivalent to:

my @doubles;
foreach (@nums) {
    push @doubles, $_ * 2;
}

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to