Hi ok ... $d_h refers ...

ok, good so far

I am looping through 6 columns ($six), and in each column, I will do ratio against two values ($tre and $tri).

And here is the problem, no ratio calculation is performed on the lines starting with printf, only a string is printed (printf prints a formatted string)

This tells me you did not call makeRatio (did not copy/paste makeRatio after UsedToBeJustDoWork and invoke makeRatio from within UsedToBeJustDoWork

Please do this and see what gets printed on stdout ... you should recognize what gets printed on stdout ... makeRatio replicates part of UsedToBeJustDoWork


So may I know if there is any article that explain that or..?

Well, perlintro and perlop and printf/sprintf

The free book Modern Perl (or http://learn.perl.org/books/beginning-perl/) might be easier to understand than perlop

If you use ppi_dumper it can help you understand the parts of a program. Here is the output of that portion

PPI::Statement PPI::Token::Word 'printf' PPI::Token::Quote::Single ''my $ratio%d_%d_%d = $$d_h[%d][%d] / $ +$d_h[%d][%d];'' PPI::Token::Operator '.' PPI::Token::Quote::Double '"\n"' PPI::Token::Operator ',' PPI::Token::Number '1' PPI::Token::Operator '+' PPI::Token::Symbol '$six' PPI::Token::Operator ',' PPI::Token::Number '1' PPI::Token::Operator '+' PPI::Token::Symbol '$tri' PPI::Token::Operator ',' PPI::Token::Number '1' PPI::Token::Operator '+' PPI::Token::Symbol '$tre' PPI::Token::Operator ',' PPI::Token::Symbol '$tri' PPI::Token::Operator ',' PPI::Token::Symbol '$six' PPI::Token::Operator ',' PPI::Token::Symbol '$tre' PPI::Token::Operator ',' PPI::Token::Symbol '$six' PPI::Token::Operator ',' PPI::Token::Structure ';'

So you see a "," comma does not terminate a statement, a statement is terminated by semicolon ";" which means all the symbols seperated by the comma operator are arguments to printf function


And is $ratio... the same as $ratio ...

I think you will have to tell me if they're the same :) Start a new file and employ ddumperBasic debugging checklist and compare the output you get (lesson courtesy of Basic debugging checklist and brian's Guide to Solving Any Perl Problem )

The books teach more about arrays and arrays of arrays, as does perldsc ...

You should spend more time with perlintro esp Perl variable types. By "spend time" I mean read it, type up at least ten ddumpering() programs , to learn what its trying to teach you, and equally important, to learn how to interpret ddumper output . The creatingfiles/typing part is important , babysteps (learning to crawl before you learn karate)


In reply to Re^17: How to store the output from foreach loop into variable/array without printing? by Anonymous Monk
in thread How to store the output from foreach loop into variable/array without printing? by hellohello1

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.