Hi Roman,

Please sort the IP addresses with this way could help you,

@list = sort { $b <=> $a } @ip_addresses;

rgds,
Rajeev


---------- Forwarded message ----------
From: Roman Daszczyszak <[EMAIL PROTECTED]>
Date: Nov 13, 2006 7:08 PM
Subject: Looking for a Perl module for proper IP sorting
To: beginners@perl.org

I have a bit of code that collects and stores all the IP addresses
used on my network.  However, when I sort the list via 'sort' the IP
addresses are listed as if they were text, so the output looks like
this:
192.168.0.1
192.168.0.100
192.168.0.101
192.168.0.114
192.168.0.115
192.168.0.116
192.168.0.117
192.168.0.118
192.168.0.119
192.168.0.12
192.168.0.120
192.168.0.121
192.168.0.122
192.168.0.123
192.168.0.124
192.168.0.125
192.168.0.126
192.168.0.127
192.168.0.128
192.168.0.129
192.168.0.13
192.168.0.130

instead of the via the 4th octet.

Is there a Perl module that does proper IP sorting?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to