#!/usr/bin/perl -w # use strict; use warnings; use Date::Calc qw(:all); ($year, $month, $day) = Today(); $Dd = -1; ($year,$month,$day) = Add_Delta_Days($year,$month,$day, $Dd); $year = $year; $month = "$month"; $day = "$day"; print "$year\n"; print "$month\n"; print "$day\n"; print "$year$month$day\n";
Surely you didn't mean to comment out use strict when it's so easy to make this script strict compliant?
and that's it!my ($year, $month, $day) = Today(); my $Dd = -1;
Anyway, the answer you're looking for is sprintf.
This will add up to two zeros for padding to give you a 2 digit number.$month = sprintf("%02d", $month);
Hope this helps.
jarich
In reply to Re: Values of day and month in two digets
by jarich
in thread Values of day and month in two digets
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |