I’m working on a Perl program at work and stuck on (what I think is) a trivial problem. I simply need to build a string in the format ’06/13/2012′ (always 10 characters, so 0’s for numbers less than 10).
Here’s what I have so far:
use Time::localtime;
$tm=localtime;
my ($day,$month,$year)=($tm->mday,$tm->month,$tm->year);
You can do it fast, only using one POSIX function. If you have bunch of tasks with dates, see the module DateTime.