Fellow Perl lovers,

I'm trying to zero fill a numeric variable (which in this case happens to be the 
current month and day).

The sprintf (%02d) function would seem a likely candidate for this, but I don't 
actually want to print the value.
It's being used as part of a filename.

I've looked at the pack function, but haven't been able to decipher from the 
documentation a template that would work.

Since in this case I only have to zero fill at most one position, here's the lengthy 
'brute force' method that I came up with:

....
my $month = length((localtime)[4] + 1) == 1 ? '0' . ((localtime)[4] + 1) : 
(localtime)[4] + 1;
my $day = length((localtime)[3]) != 1 ? (localtime)[3] : '0' . (localtime)[3];
my $monthday = $month . $day;
my $output_file = join ('_', 'resend' , $monthday , "$key");
....

Is there a more elegant way of doing this?

Thanks for your help,

Tim


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to