4.11.3. Discussion
Called in list context, the reverse function
reverses elements of its argument list. You can save a copy of that
reversed list into an array, or just use foreach
to walk through it directly if that's all you need. The
for loop processes the array elements in reverse
order by using explicit indices. If you don't need a reversed copy of
the array, the for loop can save memory and time
on very large arrays.
If you're using reverse to reverse a list that you
just sorted, you should have sorted it in the correct order to begin
with. For example:
# two-step: sort then reverse
@ascending = sort { $a cmp $b } @users;
@descending = reverse @ascending;
# one-step: sort with reverse comparison
@descending = sort { $b cmp $a } @users;