in reply to Summarizing an array of IP's
We can use some of the standard functions loaded by "Socket" module to handle ip addresses:
use Socket; use strict; use warnings; my %stat; my @addr = qw(10.0.0.1 10.0.0.2 10.0.0.3 192.168.1.5 192.168.1.6 192.168.10.3 192.168.10.4 192.168.10.5); $stat{inet_ntoa(substr(inet_aton($_), 0, 3) . "\0")} ++ foreach (@addr +); print "$_ has $stat{$_} nodes\n" foreach (keys %stat);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Summarizing an array of IP's
by carric (Beadle) on Jan 07, 2004 at 01:09 UTC | |
by pg (Canon) on Jan 07, 2004 at 02:00 UTC | |
by carric (Beadle) on Jan 08, 2004 at 01:30 UTC |