Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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??

Help for this page

Select Code to Download


  1. or download this
    $ perl -le '$,=$/; print @ARGV[ map { unpack N, substr $_, -4 } \
        sort map { eval("v$ARGV[$_]") . pack N, $_ } 0 .. $#ARGV ]' \
    ...
    1.1.1.66
    1.2.1.1
    1.11.1.1
    
  2. or download this
    $ perl -e 'printf "%vd\n", $_ for sort map { eval "v$_" } @ARGV' \
        1.2.1.1 1.1.1.1 1.11.1.1 1.1.1.66 1.1.1.9
    ...
    1.1.1.66
    1.2.1.1
    1.11.1.1
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-07-20 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    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.