in reply to Deleting trailing 0's after using sprintf

This is actually an exercise in Jeff Friedl's Mastering Regular Expressions.
His final reccomendation is to skip the sprintf alltogether and just use
$percent_change =~ s/(\.\d\d(?>[1-9]?))\d+/$1/
Which always keeps 2 digits, i.e. 2.500 => 2.50.
If you don't wan that to happen, use
$percent_change =~ s/(\.\d(?>[1-9]{0,2}))\d+/$1/



Code is (almost) always untested.
http://www.justicepoetic.net/