On Fri, Feb 01, 2002 at 02:27:13PM -0800, Robert G. Werner wrote:
> If you can be sure that slashes will be the delimiters,  slit on them
> and then add a '0' if the first two elements are less than 10:
> 
> my $date_str = "9/9/1973";
> 
> my @date_arr = split("/", $date_str);
> 
> for my $i (0 .. 1) {
>       $date_arr{$i} = $date_arr{$i} < 10 ? $date_arr{$i} : "0$date_arr{$i};
> }
> 
> $date_str = join("/", @date_arr);
> 
> Sort of long to type but that would get the job done IMHO.

You people are trying to give me an embolism.

Use sprintf to format numbers.

Maybe if I say it in a variety of languages it'll go over better.

Utilice el sprintf para formatar números
Employez le sprintf pour formater des nombres
Benutzen Sie sprintf, um Zahlen zu formatieren
Usare lo sprintf per formattare i numeri
Use o sprintf formatar números

;)

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
It's Crack Cocaine time!

Reply via email to