Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

(tye)Re: "Commifying" a number

by tye (Sage)
on Dec 13, 2002 at 06:36 UTC ( [id://219514]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: "Commifying" a number
in thread "Commifying" a number

I don't see RE: regexp for adding commas to a number failing for 3-digit numbers. If it can't commify, it makes no substitutions, which leaves the number uncommified, which is correct.

        - tye

Replies are listed 'Best First'.
Re: (tye)Re: "Commifying" a number
by Tanalis (Curate) on Dec 13, 2002 at 08:09 UTC
    Really? It just seems to "eat" the number on my system .. using the following code:
    my $number = 123; $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; print $number;

    I get no output from the print, almost as if $number if undef. If I use 1234 as the input, I get 1,234 out - which is right ..

    That's with Perl 5.004.04 on Solaris .. maybe it's a version thing.

    -- Foxcub

      If it doesn't print anything, it's a Solaris issue, not a version thing. But I find that highly unlikely. I ran the above code on all released versions of Perl since 5.000, and it prints '123' on all of them, except for the versions 5.004_68 up till 5.005_02, where it prints '1,2,3'.

      Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 22:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found