in reply to Re^2: Golf: reverse sort /etc/passwd by UID
in thread Golf: reverse sort /etc/passwd by UID
D'oh! I did omit a couple of bits didn't I (It was (obviously) untested -- I don't have an /etc/passwd).
I tried to remove the $b=~ & $a=~ bits when I noticed that reverse was one character less -- ignoring/forgetting that $_ cannot be both at the same time :(.
I don't think the (...)[0] bits are necessary, without /g only the regex will only return one (the first) match.
This should work? (still untested):
perl -E"say sort{$b=~/:(\d+):/<=>$a=~/:(\d+):/}<>" /etc/passwd
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Golf: reverse sort /etc/passwd by UID
by thundergnat (Deacon) on Feb 05, 2013 at 20:33 UTC | |
|
Re^4: Golf: reverse sort /etc/passwd by UID
by Tommy (Chaplain) on Feb 05, 2013 at 20:26 UTC | |
by thundergnat (Deacon) on Feb 05, 2013 at 20:40 UTC |