for my $location ( sort keys %activity_tran_ledg ) { for my $index (sort keys %{$activity_tran_ledg->{ $location }} ) { my $i1 = $index+1; if (exists $activity_tran_ledg{$location}{$index+1}{"index"}) { my $test = $activity_tran_ledg{$location}{$index}{"trandate"} - $activity_tran_ledg{$location}{$index+1}{"trandate"}; if ($activity_tran_ledg{$location}{$index}{"trandate"} - $activity_tran_ledg{$location}{$index+1}{"trandate"} <= 1) { # 1 second difference print "[",__LINE__,"] LOC [$location] I [$index] TDI [$activity_tran_ledg{$location}{$index}{trandate}] I1 [$i1] TDI1 [$activity_tran_ledg{$location}{$i1}{trandate}] TEST [$test]\n"; if ((($activity_tran_ledg{$location}{$index}{"reasonmsg"} eq "Scheduled Unlock") and ($activity_tran_ledg{$location}{$i1}{"reasonmsg"} eq "Scheduled Lock Sent")) or (($activity_tran_ledg{$location}{$index}{"reasonmsg"} eq "Scheduled Lock") and ($activity_tran_ledg{$location}{$i1}{"reasonmsg"} eq "Scheduled Unlock Sent"))) { print "[",__LINE__,"] *** LOC [$location] I [$index] RMI [$activity_tran_ledg{$location}{$index}{reasonmsg}] I1 [$i1] RMI1 [$activity_tran_ledg{$location}{$i1}{reasonmsg}]\n"; } } } else { } } }