I am a bit ashamed to be confused by this, but here is my problem:

I am looping through some work, and want to print out a status indicator of '.'. Every 10 iterations through the loop I want to print the decade, every 100 iterations I want to print a newline+tab.

The following just prints blanks:

 perl -e 'my $i=0;for (1..456) {print (($i%100)?"":"\n\t"),(($i%10)?".":(int(($i%100)/10)));$i++;};print "\n";'

OUTPUT:

	
	
	
	
	

If I change the print LIST to print;print; like this, it works:

perl -e 'my $i=0;for (1..456) {print (($i%100)?"":"\n\t");print (($i%10)?".":(int(($i%100)/10)));$i++;};print "\n";'

OUTPUT:

	0.........1.........2.........3.........4.........5.........6.........7.........8.........9.........
	0.........1.........2.........3.........4.........5.........6.........7.........8.........9.........
	0.........1.........2.........3.........4.........5.........6.........7.........8.........9.........
	0.........1.........2.........3.........4.........5.........6.........7.........8.........9.........
	0.........1.........2.........3.........4.........5.....

The first bit of code is using print to print a list (comma-separated) I think. I think I have all the parens in the correct places to make the order of operation correct, but perl must be applying some other strange order of operation rule that I don't understand.

FYI: perl 5.10.0 on Ubuntu 9.10


In reply to print list, comma not working? by fzellinger

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.