I would say that you should use the latter method, the one you prefer. It is more concise, easier to read, and a little more efficient.
1% and even 5% is within the margin or error of Benchmark, so that last phrase is inaccurate.
I'm actually surprised they're the same speed. @a = sort @a; is optimized to be done in place, and I think for (@a) is optimized over the more general for (LIST) (it's definitely implemented differently).
In reply to Re^2: How foreach loops decide what to iterate through
by ikegami
in thread How foreach loops decide what to iterate through
by lefthanded
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |