Originally posted by KevinADC
Now i have try some other method.I am using Time::Local module to find the record between the date range.Is it better way to sort this problem.
[CODE=perl]#!/usr/bin/perl
use Time::Local;
my $cUser_Name="ra jiv101";
my @file;
my $cYear1=2008;
my $cYear2=2008;
my $cMon1=2;
my $cMon2=2;
$cMon1-=1;
$cMon2-=1;
my $cDay2=18;
my $cDay1=18;
my $s=0;
my $m=0;
my $h=0;
while(<DATA>)
{
next if /^(\s)*$/;
my $date=(split(/#/,$_,3))[1];
local ($year,$mon,$da y)=split(/\-/,$date);
$mon-=1;
if((timelocal($ s,$m,$h,$day,$m on,$year) >= timelocal($s,$m ,$h,$cDay1,$cMo n1,$cYear1))&&( timelocal($s,$m ,$h,$day,$mon,$ year) <= timelocal($s,$m ,$h,$cDay2,$cMo n2,$cYear2)))
{
push(@file,$_) ;
}
}
print @file;
__END__
rajiv101#2008-02-16#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y
rajiv101#2008-02-17#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y
rajiv101#2008-02-17#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y
rajiv101#2008-02-18#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y
rajiv101#2008-02-18#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y
rajiv101#2008-02-19#10:06:00#19: 49:33#127.0.0.1 #19:49:54#18:18 :00#1 27.0.0.1#CY#Y[/CODE]
Regards
Rajiv
Comment