Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Separating big numbers with commas

by monkeygirl (Pilgrim)
on Sep 04, 2001 at 23:44 UTC ( [id://110138]=note: print w/replies, xml ) Need Help??


in reply to Separating big numbers with commas

The Perl Cookbook (Recipe 2.17) has just what you need:

my $number = 987654321; print commify($number); sub commify { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text }

Update: blakem is right. And besides, my answer is incomplete. For a more complete answer, look here.


Sarah
If Bill Gates can name a company after his "bedroom" problems, I can have a stupid sig that points it out.

Replies are listed 'Best First'.
Re: Re: Separating big numbers with commas
by Anonymous Monk on Aug 07, 2003 at 19:56 UTC
    nice one.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2024-04-23 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found