Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Golf: reverse sort /etc/passwd by UID

by tobyink (Canon)
on Feb 05, 2013 at 16:56 UTC ( [id://1017219]=note: print w/replies, xml ) Need Help??


in reply to Golf: reverse sort /etc/passwd by UID

How about this...

perl -e'print$_->[0]for sort{$b->[3]-$a->[3]}map[$_,split/:/],<>' /etc +/passwd

With additional whitespace, that's...

perl -e'print $_->[0] for sort { $b->[3] - $a->[3] } map [$_, split /: +/], <>' /etc/passwd
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Golf: reverse sort /etc/passwd by UID
by Tommy (Chaplain) on Feb 05, 2013 at 17:14 UTC

    Hey that's clever! ...Preserving the original line as a member (1st member) in the arrayref so you don't have call join() on the arrayref just to get the line back. *golf clap*

    Tommy
    A mistake can be valuable or costly, depending on how faithfully you pursue correction

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1017219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found