Your "formula" seems overly complicated (and probably broken). For the start, I'd go with a quick&dirty simple & minimal variant and advance from there:
#!/usr/bin/perl
use strict;
use warnings;
my @prices = qw'.1 17.95 0 10000 0.00 21 .22';
my $qtyx = 3;
print "Content-type: text/html\n\n";
print
map "$_ x $qtyx, total costs are: ". VIEWPRICE( MAKEPRICE($_)*$qtyx
+ ) .'<br />',
@prices;
sub MAKEPRICE {
(my $mp = sprintf "%.2f", (shift)) =~ tr/.//d;
return $mp
}
sub VIEWPRICE {
my $vp = sprintf "%03d", (shift);
$vp =~ s/(..)$/.$1/ or $vp = sprintf "%.2f",$vp;
return $vp
}
This prints (<br /> translated):
Content-type: text/html
.1 x 3, total costs are: 0.30
17.95 x 3, total costs are: 53.85
0 x 3, total costs are: 0.00
10000 x 3, total costs are: 30000.00
0.00 x 3, total costs are: 0.00
21 x 3, total costs are: 63.00
.22 x 3, total costs are: 0.66
Regards
mwa