http://qs321.pair.com?node_id=484405


in reply to sprintf percent formatting

sprintf is probably what you want, yet give it a slightly altered input and it'll work:

use strict; use warnings; use Test::More qw(no_plan); my $percent = sprintf("%d%%",(1/3)*100); is($percent,"33%"); print "Result: $percent\n"; $percent = sprintf("%d%%",(1/30)*100); is($percent,"3%"); print "Result: $percent\n";

Instead of '%02d%%', I now use '%d%%' which seems to be what you want.

--
b10m

All code is usually tested, but rarely trusted.