On Monday 13 November 2006 14:38, Roman Daszczyszak wrote: > 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?
http://search.cpan.org/~sarenner/Net-IPAddress-1.10/IPAddress.pm You can use the ip2num, sort and then num2ip. OR: You can represent them with IP-objects: http://search.cpan.org/~luismunoz/NetAddr-IP-4.004/IP.pm and then do the comparisment via >, <, >=, <=, <=> or cmp I've never used any, found them on search.cpan.org... -- Bjørge Solli - Office:+47 55205847 Mohn-Sverdrupsenteret, Nansensenteret, Høyteknologisenteret T47 Thormöhlensgate 47, 5006 Bergen, Norway - www.nersc.no Google Earth: www.nersc.no/GE - TOPAZ: topaz.nersc.no -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>