Wow, that's a lot of output and next to no description of your problem. But I think you are trying to print out multiplication tables. You almost have it, however, your problem is that you are incrementing both of your counters simultaneously. In fact $counter and $counting are incremented one after the other. That leads to your problem where you get 0*1, then 1*2, etc. What you want is a nested loop. That is for each $counter, you want to iterate through $counting 10 times to print out the times table for that number, then print the newline, increment $counter, and continue. Here's a basic example with for loops(They're your friend)

for my $x (1..$howmany) { print "#"; for my $y (1..10) { my $answer = $x * $y; print "|$x|*|$y|=|$answer"; } print "\n"; }

Notice how one for loop is nested in the other, so for every iteration of $x which goes from 1 through $howmany, you get 10 iterations of $y. performing the math and printing inside the second for loop and you are done. No fuss, no muss, and no tracking of several counter variables.

HTH


In reply to Re: Me no good at Xing anything by pzbagel
in thread Multiplication table by jinx

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.