Both for and map iterate over lists, but the latter has the extra purpose that it returns a transformed copy of the list. There's been optimizations that make map in void context efficient (or at least not as inefficicent as it used to be) so you could use map { do_something( $_ ) @list in place of for (@list) { do_something( $_ ) }, but it's clearer/cleaner to use for for iteration and map for transformation and not muddle the two.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re^4: How do I use the map command for this?
by Fletch
in thread How do I use the map command for this?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |