Robert Citek wrote at Thu, 03 Jul 2003 18:48:02 -0500:

> I want to format a number so that it has commas as a separator.  Here's the
> code I came up with:
> 
> my $num=12345678;
> print scalar reverse( join(",", grep( /./ ,split
> (/(...)/,reverse($num))))), "\n";
> 
> This works but was wondering if anyone might suggest a better method.

In addition to the FAQ, you can use the CPAN-Module Number::Format.
use Number::Format;
my $num = 12345678;
my $f = Number::Format->new(-thousands_sep => ',', -decimal_point => '.');
print $f->format_number($num),"\n";


Greetings,
Janek


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

Reply via email to