in reply to How foreach loops decide what to iterate through
Both methods are practically the same in terms of speed. When you do foreach (sort @a), the foreach doesn't loop over @a but instead over the anonymous (and temporary) array that was returned from the sort function.
The only difference of the two methods is that the first method stores the (anonymous) sorted array into @a before going into the foreach loop, while the second method leaves the sorted array anonymous.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How foreach loops decide what to iterate through
by jvector (Friar) on Feb 14, 2009 at 00:25 UTC | |
by jethro (Monsignor) on Feb 14, 2009 at 02:54 UTC | |
by jasonk (Parson) on Feb 15, 2009 at 18:33 UTC | |
by jvector (Friar) on Feb 15, 2009 at 22:38 UTC | |
by ikegami (Patriarch) on Feb 16, 2009 at 02:24 UTC |