When I implement the code below, I get the correct dates:
10/05/2008
10/05/2009
When I use printfinstead sprintf, I get the following:
10/05/200910/05/20081
1
Any ideas on why the printffinal prints 1?
use strict; use warnings;
my ($from_date, $to_date) = to_from_dates();
print "$from_date\n";
print "$to_date\n";
sub to_from_dates {
my ($day, $month, $year) = (localtime)[3,4,5];
my $to_date = sprintf "%02d/%02d/%04d", $month+1, $day, $year+1900;
my $from_date = sprintf "%02d/%02d/%04d", $month+1, $day, $year+1899;
return ($from_date, $to_date);
}
Wilkie
source
share