Superstition makes me post-increment; I think it’s not slower anymore but was back in the dinosaur age.
Post-increment is necessarily slower since it requires making a copy of the scalar that pre-increment doesn't. However, Perl replaces post-increment operators in void context with pre-increment operators.
$ perl -MO=Deparse -e'$_++ for @a;' ++$_ foreach (@a); -e syntax OK $ perl -MO=Deparse -e'map { $_++ } @a;' map {$_++;} @a; -e syntax OK
In reply to Re^4: map vs for\foreach.
by ikegami
in thread map vs for\foreach.
by builat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |