Actually,
you need a little more so you only get one occurence of a net per
object.
This should take care of that.
while (<>) {
chop;
if(/^\s*$/) {
%done = ();
}
if(/^di:/ || /^dom-net:/) {
($tmp,$value) = split (/\s+/, $_, 2);
printf "%-10s", $tmp;
@list = split(/\s+/,$value);
foreach $j (0..$#list) {
$net = &munge($list[$j]);
if(!$done{$net}) {
printf " %s", $net;
}
$done{$net} = 1;
}
print "\n";
next;
} else {
printf "%s\n", $_;
}
}
sub munge {
local($str) = @_;
local($ind) = 0;
local($val) = "";
local(@add) = split(/\./, $str);
foreach $ind (0..$#add) {
if ($add[0] < 128) {
$val = "$add[0]".".0.0.0";
return $val;
}
if ($add[0] < 192) {
$val = "$add[0]"."."."$add[1]".".0.0";
return $val;
}
if ($add[0] < 224) {
$val = "$add[0]"."."."$add[1]"."."."$add[2]".".0";
return $val;
}
}
}
Hope this was of some help,
--Tony.