请帮我解决这段代码
perl MCLoader_DSS.pl -sSERVERNAME -u** -p** -c321 -i511359 -H1 -C1 -a2015-07-28 > a.txt
pause
$mStartDate = $endDate;
$mStartDate =~ s/\-//g;
$mStartDate =~ s/\'//g;
$mEndDate = $endDate;
$mEndDate =~ s/\'//g;
($yy, $mm, $dd) = Add_Delta_Days(split('-', $mEndDate), 1);
$mEndDate = sprintf ('%4d-%02d-%02d', $yy, $mm, $dd);
$mEndDate = "'".$mEndDate ."'";
我在文本文件中得到的输出是
@StartDate = '2015-07-29', @EndDate = '2015-07-30'
实际上与我通过的日期不匹配
我希望实现@Startdate = [The date I pass]
,即:a2015-07-28和@EndDate = [Should add +1 to its date]
我怎样才能明确地传递这两个日期?
答案 0 :(得分:0)
看起来你要做的事情远比它需要的要困难得多。自2007年以来,Time::Piece已包含在Perl中。
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Time::Piece;
use Time::Seconds;
my $format = '%Y-%m-%d';
my $start_date = Time::Piece->strptime('2015-07-28', $format);
my $end_date = $start_date + ONE_DAY;
say $start_date->strftime($format);
say $end_date->strftime($format);