- 论坛徽章:
- 6
|
本帖最后由 RE_HASH 于 2016-05-18 00:45 编辑
$> cat aa.pl ; perl aa.pl
sub guessDate
{
$_ = shift;
my ($y, $m, $d) = /^((?:19|20)*\d{2}|0?\d{1})([01]?\d)([0-2]?\d|3[01])$/;
$y +=1900 if ($y < 100);
$y +=100 if ($y < 1950);
return sprintf "%4d%02d%02d", $y, $m, $d;
}
printf STDERR "DEBUG INFO:\n______________\n";
while (<DATA>)
{
chomp;
@A = map {guessDate($_)} split;
print STDERR "$_\tConverted to :\t", "@A", ($A[0] + 100000 > $A[1])?"\t< 10 years":"\t> 10 years", "\n" ;
($A[0] + 100000 > $A[1]) ? push @{$O->{'10 Years -'}}, $_: push @{$O->{'10 years +'}}, $_ ;
}
printf "OUTPUT:\n______________\n%s", join "\n", @{$O->{'10 Years -'}};
__DATA__
19870913 1997912
20000315 20100316
0411 0411
2004410 20140410
89112 90112
19990121 20050806
20050806 19990121
01121 02122
19901019 2016515
991201 050806
DEBUG INFO:
______________
19870913 1997912 Converted to : 19870913 19970912 < 10 years
20000315 20100316 Converted to : 20000315 20100316 > 10 years
0411 0411 Converted to : 20040101 20040101 < 10 years
2004410 20140410 Converted to : 20040410 20140410 > 10 years
89112 90112 Converted to : 19891102 19901102 < 10 years
19990121 20050806 Converted to : 19990121 20050806 < 10 years
20050806 19990121 Converted to : 20050806 19990121 < 10 years
01121 02122 Converted to : 20011201 20021202 < 10 years
19901019 2016515 Converted to : 19901019 20160515 > 10 years
991201 050806 Converted to : 19991201 20050806 < 10 years
Converted to : < 10 years
OUTPUT:
______________
19870913 1997912
0411 0411
89112 90112
19990121 20050806
20050806 19990121
01121 02122
991201 050806
|
评分
-
查看全部评分
|