in reply to Re: Commify numbers, the boring and straightforward way
in thread Commify numbers, the boring and straightforward way
Good point. And I just noticed that it doesn't properly treat signs either. Still boring and straightforward, if not quite so trivial:
sub commify { my ( $sign, $int, $frac ) = ( $_[0] =~ /^([+-]?)(\d*)(.*)/ ); my $commified = ( reverse scalar join ',', unpack '(A3)*', scalar reverse $int ); return $sign . $commified . $frac; }
It should behave exactly like the FAQ code, and some shallow testing seems to confirm that.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Commify numbers, the boring and straightforward way
by halley (Prior) on Mar 02, 2005 at 15:07 UTC | |
by Aristotle (Chancellor) on Mar 02, 2005 at 17:14 UTC |