in reply to RE: RE: regexp for adding commas to a number
in thread regexp for adding commas to a number

The easy way to deal with open ended floating pointed nums is to simply remove the floating part until the commas are added, then reattach.
$integer =~ s/(.*)(\.\d\d+)$/$1/; $float = $2; # do stuff $integer .= $float;

Replies are listed 'Best First'.
RE: RE: open ended floats
by AltBlue (Chaplain) on Aug 18, 2000 at 11:27 UTC
    lol. isn't that what i'm currently doing ?! :))
    plz check up again my previous post and look at the final code - it does exactly that :)
    your snippet doesn't work for 'real' strings like: 'for every 1234.567 blah stuff there is some 34% rate of foobar success at every 9876543.876543 seconds'

    --
    AltBlue.

RE: RE: open ended floats
by Adam (Vicar) on Aug 18, 2000 at 02:05 UTC
    It would be more efficient to use split.
    my( $int, $float ) = split /\./, $num;