Of course, this code is very locale-specific. For one thing, what if the current locale uses `,' instead of `.' as the decimal separator? Then inserting commas as period separators is not a good idea. Also, what if the currency symbol is not `$'? Of course, C-style locales have their own problems; see, for example, the SECURITY section of the perllocale(1) manpage.

In addition, it loses accuracy. You don't always want to lose the ability to represent fractions of cents.