
mhx
Enthusiast
/ Moderator
Aug 16, 2001, 11:48 AM
Post #4 of 5
(279 views)
|
Give this subroutine a try:
sub FormatValue ($) { my $v = reverse shift; $v =~ s/(\d{3})(?=\d+$)/$1,/g; scalar reverse $v; } It works for arbitrary length integer and floating point numbers. For example,
print FormatValue '1234567890123.12456789', "\n"; print FormatValue '1234567890123', "\n"; will print
1,234,567,890,123.12456789 1,234,567,890,123 Hope this helps. -- Marcus
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= ($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"
|