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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |