My program is sort of working except, it is not picking up some of the elements,and it
seems to happen when it gets close to the reading the end of the file, usually when the emails have dots in the name. It works fine when the emails do not have any dots in the name. I don't know why because at the start of the file it does contain emails with dots and it is printing them out ok. Any suggestions?
Thanks for your help,
olmos
.
...
while (<INFO>)
{
chomp;
@elements = split(/,{1,}/);
$ipaddress = $elements[0];
$user = "$elements[1]";
$sysadmin = "$elements[2]";
($ip1, $ip2, $ip3, $ip4) = split(/\./,$ipaddress);
## Checking to see if there was no third element...
if ($sysadmin eq $null)
{
$sysadmin = "$user";
}
## Checking to see whether or not we have a new subnet...
if ($ipsubnet eq "0"

{
## First time through...
push(@subnetemail, $sysadmin);
$ipsubnet = $ip3;
$classip = "$ip1\.$ip2"; ## This is the first, so we need a
classip...
}
elsif ($ipsubnet ne $ip3)
{
## This is a unique subnet -- time to print out the last subnet
$oipsubnet = $ipsubnet;
$ipsubnet = $ip3;
@uniquemail = grep { ! $seen{$_} ++ } @subnetemail;
$addcomma = join(", ", @uniquemail);
print "$emailprogrampath $messagepath \"$reportpath\\$classip.$oipsubne
t$filetype\" " .
"-t $addcomma -noh2 -b $sender -s \"$subject $classip\.$oipsubnet
.x \" \n" ;
$trash = splice(@subnetemail, 0); ## Clearing out the @subnetemail a
rray...
@subnetemail = $trash;
$classip = "$ip1\.$ip2"; ## Build the classip for this new
subnet.
## First time through...
push(@subnetemail, $sysadmin);
$ipsubnet = $ip3;
$classip = "$ip1\.$ip2"; ## This is the first, so we need a
classip...
}
elsif ($ipsubnet ne $ip3)
{
## This is a unique subnet -- time to print out the last subnet
$oipsubnet = $ipsubnet;
$ipsubnet = $ip3;
@uniquemail = grep { ! $seen{$_} ++ } @subnetemail;
$addcomma = join(", ", @uniquemail);
print "$emailprogrampath $messagepath \"$reportpath\\$classip.$oipsubne
t$filetype\" " .
"-t $addcomma -noh2 -b $sender -s \"$subject $classip\.$oipsubnet
.x \" \n" ;
$trash = splice(@subnetemail, 0); ## Clearing out the @subnetemail a
rray...
@subnetemail = $trash;
$classip = "$ip1\.$ip2"; ## Build the classip for this new
subnet.
push(@subnetemail, $sysadmin);
}
else
{
## This is another of the same subnet we are already looking at.
push(@subnetemail, $sysadmin);
}
} # end while
@uniquemail = grep { ! $seen{$_} ++ } @subnetemail;
$addcomma = join(", ", @uniquemail);
print "$emailprogrampath $messagepath \"$reportpath\\$classip.$ip3$filetype\" -
t $addcomma -noh2 -b $sender -s \"$subject $classip\.$ip3.x \" \n";
close(INFO); # Close the file