Hi Reggie!

> -----Original Message-----
> From: Johnson, Reginald (ECCS) [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 14, 2003 11:32 AM
> To: '[EMAIL PROTECTED]'
> Subject: printing number with commas in it
> 
> 
> I am trying to print a number with commas in it. I cannot find 
> the correct syntax to do this with printf.
> I considered using the substr function but this depends on 
> mealways knowing the size of the number.
> Can you help me with this?
> 
> 
> Reggie
> 

>From the Perl Cookbook (2.17):

sub commify
{
  my $text = reverse $_[0];
  $text =~ s/(\d\d\d)(?=\d)(?!\d*.)/$1,/g;
  scalar reverse $text;
}

Baring my typos, this works on a numeric string
even with a decimal point.

Aloha => Beau;



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

Reply via email to