fiddling around with a commify sub, and found this.. bug?
[email protected] ("Scott R. Godin")
| Newsgroups | perl.macperl.porters |
|---|---|
| Organization | Laughing Dragon Services |
| Message-ID | <[email protected]> |
#!perl
sub commify ($@) {
my $sep = shift;
my @input =
map {
my $tmp = reverse;
$tmp =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
scalar reverse $tmp
} @_;
return join("$sep", @input);
}
my @val = (87264867324.723474, 972472343.10, 12658125, 7846764984085);
print commify("\n", @val), "\n\n";
# and just to be sure...
print scalar 87264867324.723474;
# is scalar supposed to round ?
-=-
87,264,867,324.7235
972,472,343.1
12,658,125
7,846,764,984,085
87264867324.7235
--
Scott R. Godin | e-mail : [email protected]
Laughing Dragon Services | web : http://www.webdragon.net/
It is not necessary to cc: me via e-mail unless you mean to speak off-group.
I read these via nntp.perl.org, so as to get the stuff OUT of my mailbox. :-)