in reply to Re: converting "30k" string to integer
in thread converting "30k" string to integer

99.44% pure!

I modded it to have ([kKmMgG]b?B?) and {lc($2)} for case insensitivity and it's just what I needed. Thanks!

If speed becomes an issue, I'll check out the other suggestions here - thanks to all!

Replies are listed 'Best First'.
Re: Re: Re: converting "30k" string to integer
by CombatSquirrel (Hermit) on May 16, 2003 at 13:35 UTC
    You might want to use ([kKmMgG][bB]?) instead of ([kKmMgG]b?B?). Your version will recognize "3gbB" as well as "3gB", although the first version is not a key in the hash. Its undef value will be converted to 0, so that you will have that string replaced with "0".