Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by thundergnat (Deacon)
on Feb 05, 2013 at 20:40 UTC ( #1017281=note: print w/replies, xml ) Need Help??


in reply to Re^4: Golf: reverse sort /etc/passwd by UID
in thread Golf: reverse sort /etc/passwd by UID

No, no. It doesn't work (tested and confirmed).

The sort block operates on the global variables $a and $b. A match without an explicit variable operates on $_. There is nothing mapping $a and $b to $_ there, so the sort block is just comparing 0 to 0 and leaving the order alone. The fact that /etc/password is in a "sorted" order makes it SEEM like it is working... but it isn't.

print reverse sort{/(:\d+:)/<=>/(:\d+:)/}<DATA>; __DATA__ aaa:5: bbb:3: ccc:1: ddd:7: eee:8:
eee:8:
ddd:7:
ccc:1:
bbb:3:
aaa:5:

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017281]
help
Chatterbox?
[Corion]: A good morning everybody!
Corion watches with pleasure that Future::AsyncAwait now also works on 5.16. I think 5.14 is a good baseline for "modern" Perl, and that's only one release away from 5.16
[Corion]: (and I really like the async and await keywords as they do away with lots of anonymous subroutines)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2018-01-24 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (256 votes). Check out past polls.

    Notices?