Could any one help me to compare the date value say at 10th column with sysdate (i.e current date) and if diffrence is more than 50 days then filter them out from the file. The file contain 10000 records.
head file
00971502657744 A671FAHP2EW8BG1369172011HRWS contact information 2010-12-30 2010-12-30
8500411188 S561FAHP2EW8BG1400762011QIJW contact information 2010-12-30 2011-01-01
0505801003 S871FAHP2EW8BG1401572011MSNL contact information 2010-12-29 2010-12-30
821198238127 K981FAHP2EW9BG1171772011FORD Secret data 2010-12-31 2010-12-31
821094025539 K341FAHP2EW9BG1189922011QAQO Secret data 2011-01-02 2011-01-02
0551088849 S341FAHP2EW9BG1401182011NIAS contact information 2010-12-30 2011-01-01
#!/usr/bin/perl
use strict;
use Time::Local;
sub diffT {
my ($segIni,$minIni,$hourIni,$dayMonthIni,$monthIni,$yearIni)=@_;
$monthIni-=1;
my $begin = timelocal($segIni,$minIni,$hourIni,$dayMonthIni,$monthIni,$yearIni);
my ($seg, $min, $hours, $dayMonth, $month, $year, $dayWeek, $dayYear, $save) = localtime();
$year+=1900;
my $final = timelocal($seg,$min,$hours,$dayMonth,$month,$year);
my $diffSeg = $final - $begin;
$diffSeg;
}
open(DAT,shift) or die "Unable to open file \n";
while (<DAT>) {
chomp;
/.+(\d\d\d\d)-(\d\d)-(\d\d)\s*$/;
print $_ . "\n" if ( int(&diffT(0,0,0,$3,$2,$1)/(24*60*60)) > 50 );
}
close (DAT);