用perl实现合并txt文件内容到一个txt中
用perl实现:输入日期范围20180401,20180501,读取在范围内的所有日期文件夹比如(20180412)下的相对应的日期txt,并且合并输出到一个txt中...
用perl实现:输入日期范围20180401,20180501,读取在范围内的所有日期文件夹比如(20180412)下的相对应的日期txt,并且合并输出到一个txt中
展开
1个回答
展开全部
#! c:/Perl/bin/perl.exe
use Tk;
use Tk::DateEntry;
use Time::Local;
my($sec,$min,$hour,$day,$mon,$year) = localtime();
$mon++;$year += 1900;
$mon1 = $mon -1;
$data_now = sprintf("%04d-%01d-%02d",$year,$mon,$day);
$data_no = sprintf("%04d-%01d-%02d",$year,$mon1,$day);
$mw = MainWindow->new();
$mw->geometry( '250x80' );
$mw->resizable( 0, 0 );
$mv = $mw->Frame() ->pack( -side => 'bottom', -fill => 'both' );
$label = $mw->Label( -text=>'From:' )->pack( -side=>'left' );
$form = $mw->DateEntry
(-textvariable => \$data_no,
-dateformat => 2,
-parsecmd=>sub {
my ($y,$m,$d) = ($_[0] =~ m/(\d*)\-(\d*)\-(\d*)/);
return ($y,$m,$d);
},
-formatcmd=>sub {
sprintf ("%d-%d-%d",$_[0],$_[1],$_[2]);
}
)->pack( -side=>'left' );
$label = $mw->Label( -text=>'To:' )->pack( -side=>'left' );
$to = $mw->DateEntry
(-textvariable => \$data_now,
-dateformat => 2,
-parsecmd=>sub {
my ($yo,$mo,$do) = ($_[0] =~ m/(\d*)\-(\d*)\-(\d*)/);
return ($yo,$mo,$do);
},
-formatcmd=>sub {
sprintf ("%d-%d-%d",$_[0],$_[1],$_[2]);
}
)->pack( -side=>'left' );
$mv->Button( -text=>'Quit', -command=>sub{ exit } )->pack( -side=>'right' );
$mv->Button( -text=>'OK',-command=>\&main )->pack( -side=>'left' );
MainLoop;
sub main {
my $date1 = "$y/$m/$d";
my $date2 = "$yo/$mo/$do";
my $flag = Date_Cmp($date1, $date2);
if($flag < 0) {
print "date1 is earlier!\n";
}
elsif($flag == 0) {
print "the two dates are identical!\n";
}
else {
print "date2 is earlier!\n";
}
}
才20财富
追问
我这儿没有这个块,能用perl自带的块解决这个问题吗,大佬
追答
也可以,手动输入日期。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询