On Friday, November 29, 2002, at 08:33  AM, Vic Norton wrote:

I'll have to admit that I haven't gone through most of the cookbook, but I use

sub commify { # commify a number. Perl Cookbook, 2.17, p. 64
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}

every day. I like my numbers to look right.
I talked with Sean Burke a couple years ago at TPC, and he was advocating for a printf() format field that would do this natively, respecting locale settings. Would be nice.

-Ken



Reply via email to