##
my $total = 0;
# Total
$total += $_->[1] for @items;
# Parts (e.g. 1/10)
$_->[2] = $_->[1] / $total for @items;
# Greatest (for width)
my $highest = 0;
$_->[2] > $highest and $highest = $_->[2] for @items;
####
my $width = 300; # Width for 100%
my $html = '';
for (@items) {
my $part = $_->[2] / $highest;
my $pixels = int(.5 + $part * $width);
my $percentage = int(l5 + $_->[2] * 100);
$html .= "$_->[0] " .
"' .
"$percentage% ($_->[1])" .
' ';
}
$html .= '
';
####
template_foo($html);