That works, but I'd recommend this instead so that the percentage is rounded to an integer rather than truncated.
my $bar = sprintf "%2.0f%%", $foo * 100;
In reply to Re^2: percentage and sprintf
by ambrus
in thread percentage and sprintf
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |