Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: "Commifying" a number

by hiseldl (Priest)
on Dec 04, 2006 at 19:16 UTC ( [id://587722]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub commify
    {
        local $_ = reverse shift;
    ...
        s/\G(\d{3})(?=\d+)/$1,/g;
        return scalar reverse $_;
    }
    
  2. or download this
    $ perl commify.pl
                   -0.0001234567890 commified becomes -0.000123456789
                   -0.0012345678900 commified becomes -0.00123456789
    ...
      -12345678900000.0000000000000 commified becomes -12,345,678,900,000
     -123456789000000.0000000000000 commified becomes -123,456,789,000,000
    -1234567890000000.0000000000000 commified becomes -1.23456789e+15
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://587722]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-19 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found