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


In reply to Re: Multiplication problem by mwah
in thread Multiplication problem by John Vanbeek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.