Connie -
Try this (not really much better) from Perl Cookbook #2.17:
use strict;
use warnings;
my $num = commify (1_000_000);
print "$num\n";
sub commify
{
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse ($text);
}
Aloha => Beau.
-----Original Message-----
From: Connie Chan [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 29, 2002 9:13 PM
To: [EMAIL PROTECTED]
Subject: Any better way to make 1000000 becomes 1,000,000 ?
my $num = 1000000; # or whatever integer;
$num = reverse($num);
$num =~ s/(\d{3})/$1,/g;
chop $num if $num =~ /,$/;
$num = reverse($num);
print $num;
I have this script to make an integer with comma at every 3 digits, from
right to left.
(What should this presentation way name actaully ?? ) Like 123456 will
becomes 123,456.
Is there anyway can making this simpler ? Can sprintf help ?
Another question is that how can I use 16 digits long integer ? Any LongInt
there ?
Rgds,
Connie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]