in reply to Re: Golf: reverse sort /etc/passwd by UID
in thread Golf: reverse sort /etc/passwd by UID
Does this work?
perl -E"say reverse sort{/(:\d+:)/<=>/(:\d+:)/}<>" /etc/passwd
No, it does not work.
In the sort compare function the current records are in $a and $b but you are not accessing the current record in your example.
The comparison operator <=> puts its operands into scalar context and the match operator in scalar context returns TRUE or FALSE so you are not comparing the contents of the capturing parentheses.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Golf: reverse sort /etc/passwd by UID
by Tommy (Chaplain) on Feb 05, 2013 at 20:36 UTC | |
by thundergnat (Deacon) on Feb 05, 2013 at 20:46 UTC | |
by Tommy (Chaplain) on Feb 05, 2013 at 20:53 UTC |
In Section
Meditations