ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
4.10. Reversing an ArrayProblemYou want to reverse an array. SolutionUse the # reverse @ARRAY into @REVERSED @REVERSED = reverse @ARRAY; Or use a for ($i = $#ARRAY; $i >= 0; $i--) { # do something with $ARRAY[$i] } DiscussionThe If you're using # 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; See AlsoThe |