Not ideal (not exactly 60 mins 0 seconds and won't work either side of midnight) but try this
#!perl
use strict;
use warnings;
## add this
my $MAX_AGE = 60; # minutes
# calc cut off date time
my @mth = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @f = localtime();
my $TODAY = sprintf "%02d/%s/%4d",$f[3],$mth[$f[4]],$f[5]+1900;
my $START_MINUTE = $f[2]*60+$f[1] - $MAX_AGE;
print "Now is $TODAY $START_MINUTE mins\n";
##
my %users;
my %conn;
while (<DATA>) { # I use DATA handle instead of $fh for convenience
if( /\bBIND\b/ ) {
my( $conn, $uid ) = /conn=(\d+).*uid=(.*?),/;
$conn{$conn} = $uid;
}
if( /SRCH=Q/ ) {
my ($timestamp, $conn) = /\[(.*?)\] conn=(\d+)/;
## add this
my ($date,$h,$m,undef) = split ':',$timestamp,4;
next unless ($date eq $TODAY);
my $minutes = $h*60 + $m;
print $timestamp." = $date $h $m ; $minutes <=> $START_MINUTE\n";
##
# add condition
if ($minutes >= $START_MINUTE){
my $uid = $conn{$conn};
++$users{$uid};
}
}
}
for my $uid (keys %users) {
my $count = $users{$uid};
print "\t=> Bad user $uid ! count = $count\n" if $count > 3;
}
poj |