On Sep 9, Errin Larsen said:

>However, I need to pass that variable to another system command which
>expects any "day" value less than 10 to have a leading zero, so 7th
>day of the month should say '07'.  How can I check for that leading
>zero?  If it's missing, I know I could easily:
>
>$option = "0".$option;

I'd suggest sprintf():

  my $two_digit_day = sprintf "%02d", $one_or_two_digit_day;

To remove them, simply do:

  $date =~ s/^0+//;

That will remove all leading zeroes from a string.

-- 
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to