in reply to Sorting an array of lines
print sort { my ($aa) = $a =~ /(\d+)\s*$/; my ($bb) = $b =~ /(\d+)\s*$/; $bb <=> $aa; } <DATA>; __DATA__ 10.47.147.0 Free: 63 In-use: 99 P_InUse: 61 10.47.147.0 Free: 63 In-use: 99 P_InUse: 65 10.47.147.0 Free: 63 In-use: 99 P_InUse: 70 10.47.147.0 Free: 63 In-use: 99 P_InUse: 69 10.47.147.0 Free: 63 In-use: 99 P_InUse: 63 10.47.147.0 Free: 63 In-use: 99 P_InUse: 66
|
---|