jaybode has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on converting a suffix'd number to real number

Replies are listed 'Best First'.
Re: converting a suffix'd number to real number
by syphilis (Archbishop) on Nov 09, 2009 at 09:31 UTC
    In the absence of any description of what you're trying to do:
    $real_number = $suffixed_number + 0;
    Cheers,
    Rob
Re: converting a suffix'd number to real number
by Jenda (Abbot) on Nov 09, 2009 at 16:54 UTC

    Any chance you mean something like 1.47MLN, 4.718BLN, 1.88TRI?

    my %multipliers = (MLN => 1_000_000, BLN => 1_000_000_000, TRI => 1_00 +0_000_000_000); ... $value = $1 * $multipliers{$2} if $value =~ /^([+-]?\d*\.?\d+)\s*(MLN|BLN|TRI)$/;

    Yep, guys, I have seen things like this in some data feeds.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.