Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Welcome to the Monastery
 
PerlMonks  

Re^2: Sorting ip addresses quickly

by Anonymous Monk
on Nov 24, 2010 at 13:43 UTC ( #873440=note: print w/ replies, xml ) Need Help??


in reply to Re: Sorting ip addresses quickly
in thread Sorting ip addresses quickly

print sort map { s/(\d+)/$1/eg ; $_ } <DATA>; __DATA__ 192.168.7.10 192.168.1.2 192.168.6.10 10.10.254.253


Comment on Re^2: Sorting ip addresses quickly
Download Code
Re^3: Sorting ip addresses quickly
by salva (Monsignor) on Nov 24, 2010 at 15:19 UTC
    obviously that doesn't work:
    print sort map { s/(\d+)/$1/eg ; $_ } <DATA>; __DATA__ 192.168.6.10 10.10.254.253 10.10.254.3
      To make it work you'd need to use something like
      print map { $$_[0] } sort { $$a[1] <=> $$b[1] } map { [ $_, join '', map { sprintf '%03d', $_ } /(\d+)/g ] } <DATA>; __DATA__ 192.168.6.10 10.10.254.253 10.10.254.3
      update: oh look, thats what the root post is about, lol

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2013-05-20 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (412 votes), past polls