Sorry, I realize now that putting those two sentences next to each other probably made my post a bit confusing. When I said "using map purely for its side-effects", I was referring to these lines in the OP's code:
map { printf "%15s to %-15s\n", $_->[0],$_->[1] } pairs @legs; map { if ($info{$_->[0]}{state} ne $info{$_->[1]}{state}) {say "Mann +Act!"} } pairs @legs; map { $info{$_[0]}{"state"}=$_[1] } pairs mesh @trip, @states;
The return value of map is completely ignored, and instead actions are taken inside the code block that have side effects. These are the cases where I think a for statement modifier would be better.
On the other hand, the code that I showed, map {@arr[$_,$_+1]} 0..$#arr-1 does not make any modifications to the @arr, and I do use the return value - so this is a case where I would perfer map over for.
In reply to Re^3: Fence vs. Posts
by haukex
in thread Fence vs. Posts
by rodinski
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |