Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Splitting every 3 digits?

by stefp (Vicar)
on Sep 29, 2001 at 05:34 UTC ( [id://115558]=note: print w/replies, xml ) Need Help??


in reply to Splitting every 3 digits?

A related problem that may well be the underlying motivation of the question: writing an integer by block of three digits separated by underscores. The custom is to start from the end because the goal is to make visible thousands, millions and so on. The easy way:
$_=5544443333111; $_=reverse; s/(\d{3})/$1_/g; $_=reverse; s/^_//; print;

-- stefp

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2025-05-23 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.