-
慕田峪4524236
#!/usr/bin/perluse strict;use warnings;use Time::Local; #自带日期模块my $input = shift;my ($year, $mon, $day) = $input=~/(\d{2})(\d{2})(\d{2})/;my $today = time();my $other_day = timelocal(0,0,0,$day,$mon-1, $year);my $diff = $other_day - $today;printf "It is %.2f days ", abs($diff/(60*60*24));print $diff>0? "in the future\n" : "ago\n";
-
慕无忌1623718
模块不用另外装的。本来就有,连载入都不用啊,除非你的版本特别老?以下是一些时间的常见用法。你自己直接用这些函数就好了,我做了简单的注解。my $t=time; # 得到时间,不过是一串数字my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($t); #也可以用=gmtime$year+=1900; # $year变量的意思是since 1900my @months = qw (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); # count since 0message("$year-$months[$mon]-$mday $hour:$min:$sec, isdst: $isdst, day: $mday"); # number of seconds since Jan 1st, 1970
-
犯罪嫌疑人X
程序我没有办法帮你实现了。我只能告诉你思路。把你的输入的日期 转换为unix时间截,然后再取系统时间截 。时间截好像是从1970-01-01 00:00:00 开始算起的。通常是一组数字,如[fy138@mail ~]$ perl -e 'print time()'1313997257