use strict; my @arr = (qw(8 30)); print "arr: @arr\n"; foreach (sort @arr) { print "sorted: $_\n"; } foreach (reverse sort @arr) { print "reversed: $_\n"; } my @arr2 = (qw(1 30)); print "arr2: @arr2\n"; foreach (sort @arr2) { print "sorted: $_\n";} foreach (reverse sort @arr2) { print "reversed: $_\n"; } my @arr3 = (qw(8 40)); print "arr3: @arr3\n"; foreach (sort @arr3) { print "sorted: $_\n"; } foreach (reverse sort @arr3) { print "reversed: $_\n"; }