Start_Time | End Time | TEXT
2009-07-22 08:00:00|2009-07-22 08:00:00|blablalblabla
2009-07-22 01:00:00|2009-07-22 01:00:00|blablalblabla
2009-07-22 08:00:00|2009-07-22 21:00:00|blablalblabla
2009-07-22 23:00:00|2009-07-23 00:00:00|blablalblabla
2009-07-22 23:00:00|2009-07-23 02:00:00|blablalblabla
####
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);
####
Interval 2009-07-22 08:00:00 - 2009-07-22 08:00:00
Hour 1 :Not Match
Hour 11:Not Match
Interval 2009-07-22 01:00:00 - 2009-07-22 01:00:00
Hour 1 :Match
Hour 11:Not Match
Interval 2009-07-22 08:00:00 - 2009-07-22 21:00:00
Hour 1 :Not Match
Hour 11:Match
Interval 2009-07-22 23:00:00 - 2009-07-23 00:00:00
Hour 1 :Not Match
Hour 11:Not Match
Interval 2009-07-22 23:00:00 - 2009-07-23 02:00:00
Hour 1 :Match
Hour 11:Not Match