Sorry to bring so much confusion to this problem. Let me explain my comment as to why I wanted to avoid math.

$file = 100+ lines of 12 field comma delimited text and numbers (text,text,num,num,num,...) there are no decimals in these numbers.

$bar = a number from 0 thru 9 that will be given to me by the third field in one 12 field comma delimited line. This number will determine the number of decimal spaces that the other fields in that same line will have.

$foo = numerical fields number 4 thru 8.

I thought I could say something like:
if $bar = x then put a "." x+1 characters in from the right of $foo.
as opposed to saying:

if $bar = 2 then $foo * .01 .. printf...
if $bar = 3 then $foo * .001 printf ...
if $bar = 4 then $foo * .0001 printf...

So this is why I thought that it would be easier not to do math.
I'm really sorry about not explaining myself properly.
Hope this helps.

In reply to Re: Help with decimals by La12
in thread Help with decimals by La12

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.