my @hours (1, 11) ; # Hours to check open (FILE,"file.txt") or die "$!;"; ; # Skip first line while (){ # Correction after [ack] comment chomp; my ($start_date,$stop_date,$text) = split '|'; print "\nInterval $start_date - $stop_date\n"; foreach my $hour(@hours){ if( ($start_date to $stop_date) contains $hour){ # pseudo code print "Hour $hour: Match"; }else{ print "Hour $hour:Not Match"; } } close(FILE);