From: "Johnson, Reginald (ECCS)" <[EMAIL PROTECTED]> > 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?
use Interpolation NUM => 'commify'; $cost = 1245782; print "The cost is $NUM{$cost}.\n"; or (if you do not want the .00) use Interpolation NUM => sub { (my $cost = reverse(shift())) =~ s/(\d{3})/$1,/g; return scalar(reverse($cost)) }; $cost = 1245782; print "The cost is $NUM{$cost}.\n"; (Interpolation.pm may be installed from CPAN and via PPM) Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]