in reply to Chess Board Single Loop

Have you considered using the 'modulus' operator:
#!/usr/local/bin/perl5.8.8 -w for $x ( 1.. 64 ){ printf "%2d ", $x; printf "\n" if (($x % 8)==0); } [401] ; ./test.pl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

Replies are listed 'Best First'.
Re^2: Chess Board Single Loop
by Limbic~Region (Chancellor) on Oct 04, 2013 at 13:03 UTC
    bigsipper,
    I upvoted this node because it is the same idea I would have used. Here is how I would have written it:
    #!/usr/bin/perl use strict; use warnings; for my $x (1 .. 64) { printf("%.2d ", $x); print "\n" if not $x % 8; }
    I noticed in another thread where you indicated you have been programming Perl for 13 years. That's longer than myself as I have only been at it for 11. I find it odd with so many years of experience that you still use the -w flag rather than the lexically scoped warnings pragma and chose to treat $x as an undeclared global. These things have been considered best practices for ages. Is there a reason you don't use them?

    Cheers - L~R