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