in reply to Correct Loop Structure
open (LOG, "$fw_logfile") or die and mail_error($!); open (OUTFILE, "+>>$outfile") or die and mail_error($!); my %newIPseen; foreach my $i ( @newips ) { $newIPseen{$i} = 0; } while (<LOG>) { foreach $i ( keys( %newIPseen ) ){ unless ( $newIPseen{$i} == 500 ) { print OUTFILE if (/\;drop;[^"]*$i/) && $newIPseen{$i}++; } } }
Now, if you load the hash %newIPseen in the first place instead of the array @newips, you can get rid of the first foreach loop.
|
|---|