in reply to Date displaying the 0's

And given how sprintf takes args, you can reduce your 5 lines to just these two (taking advantage of localtime's default behavior, using an array slice on that, and doing the arithmetic in the sprintf call):
my ( $mday, $mon, $year ) = (localtime())[3..5]; my $date = sprintf("%04d-%02d-%02d", $year+1900, $mon+1, $mday);