Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^3: How to sort IP addresses

by AltBlue (Chaplain)
on Jan 31, 2007 at 10:37 UTC ( [id://597519]=note: print w/replies, xml ) Need Help??

in reply to Re^2: How to sort IP addresses
in thread How to sort IP addresses

Hm, golfing with GRT? No idea how, but anyway, here's a possible starting point:
$ perl -le '$,=$/; print @ARGV[ map { unpack N, substr $_, -4 } \ sort map { eval("v$ARGV[$_]") . pack N, $_ } 0 .. $#ARGV ]' \
OTOH, that previous version could easily be golfed (ok, just a little) by dropping the initial map (which is useful only when using this snippet "for real" - you know, using sprintf and returning a list):
$ perl -e 'printf "%vd\n", $_ for sort map { eval "v$_" } @ARGV' \

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-06-14 22:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.