How about..

   if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) {
                 $IP{$1}++;
}

the your array of unique IPs is just keys %IP


R

At 14:14 20/09/2002 +0100, Griggs Rob wrote:
>Hi All,
>
>Whats the easiest way to remove duplicate entries from an array. Below is a
>script that removes ip addresses from a log file and adds them to an array.
>I then check the array to see if the value is already present and if it is i
>set a flag($exists) and then push that value into the array if $exists is
>false.
>
>Is there an easier way?
>
>_____________START_____________
>
>open(ADD_FIRE,"+</var/log/add_firewall") || die "Unable to open file\n";
>
>open(LOG,"/var/log/testlog") || die "Unable to open file\n";
>
>         while(<LOG>) {
>                 chomp;
>                         $exists = 0;
>
>                 if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) {
>                 $address = $1;
>                         foreach(@ipadds) {
>                                 $exists = 1 if($_ eq $address);
>
>}
>                 push(@ipadds,$address) if !$exists;
>
>}
>}
>close(LOG);
>close(ADD_FIRE);
>
>         foreach(@ipadds) {
>         print "$_\n";
>}
>
>___________END___________
>
>
>--
>Email Disclaimer can be viewed at:
>http://www.netscalibur.co.uk/email.html
>--
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to