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);
In reply to Re: Summarizing an array of IP's
by pg
in thread Summarizing an array of IP's
by carric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |