Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Sebastian Stumpf
> > Please sort the IP addresses with this way could help you, > > > > @list = sort { $b <=> $a } @ip_addresses; > Wouldn't this do the same kind of sort I've been doing (aka a textual > one)? No, I don't think so. > perl -MSocket -wle 'print for map { inet_ntoa($_) } sort map > { inet_aton($_) }

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Roman Daszczyszak
Please sort the IP addresses with this way could help you, @list = sort { $b <=> $a } @ip_addresses; Wouldn't this do the same kind of sort I've been doing (aka a textual one)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Roman Daszczyszak
my @sorted = sort { my @a = $a =~ /(\d+)/g; my @b = $b =~ /(\d+)/g; shift @a <=> shift @b or shift @a <=> shift @b or shift @a <=> shift @b or shift @a <=> shift @b } @ips; Rob Thanks, that did it! Now I have to figure out why that works... hmm.. Roman -- To unsubscribe, e-

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread John W. Krahn
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.

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Rob Dixon
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.

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread kilaru rajeev
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 T

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Sebastian Stumpf
On Mon, 13 Nov 2006 14:38:25 +0100 "Roman Daszczyszak" <[EMAIL PROTECTED]> wrote: > Is there a Perl module that does proper IP sorting? I think you could use NetAddr::IP for that job. Or something simpler like that: use Socket; @sorted = map { inet_ntoa($_) } sort map { inet_aton($_) } @unsorted;

Re: Looking for a Perl module for proper IP sorting

2006-11-13 Thread Bjørge Solli
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.16