#!/usr/bin/perl -w use strict; my $log = './log'; my ($count1, $dst, $service, %count, %hash); my $ip = '24.248.36.97'; open (LOG, $log) or die "Can't open $log: $!"; while (){ ($dst, $service) = (split /;/)[11, 12]; $count1++ if ($dst =~ /$ip/); %hash = (service => $service); foreach my $key ($hash{service}){ $count{$key}++; } } foreach my $key1 (keys %count){ print "There are at least 5 occurences of $key1 and $ip.\n" if ($count{$key1} >= 5 && $count1 >= 5); }