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
In reply to Re: When would you choose foreach instead of map?
by dvergin
in thread When would you choose foreach instead of map?
by jpfarmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |