Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: (tye)Re: "Commifying" a number

by Tanalis (Curate)
on Dec 13, 2002 at 08:09 UTC ( [id://219528]=note: print w/replies, xml ) Need Help??


in reply to (tye)Re: "Commifying" a number
in thread "Commifying" a number

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

Replies are listed 'Best First'.
Re: "Commifying" a number
by Abigail-II (Bishop) on Dec 13, 2002 at 12:30 UTC
    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://219528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-16 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found