in reply to Summarizing an array of IP's

Just a little fun, assuming (gasp) sorted input.
#!/usr/bin/perl use strict; use warnings; my $pip=""; my $ctr=0; while (<DATA>) { chomp; s/\.\d+$//; if ($pip ne $_ && $pip ne"") { print "$pip has $ctr entries\n"; $ctr=1; } else { $ctr++; } $pip=$_; } __DATA__ 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.46 192.168.10.5
Enjoy,
dageek