in reply to Perl & modulus

Exactly what I needed. Thank you!

I am trying to perform a loop, it counts from 0 to $i, and it should do something every $x times, while still looping. Modulus is what I needed.

I just didn't know it was the solution to both of my questions :)

Detonite

Replies are listed 'Best First'.
Re^2: Perl & modulus
by Anonymous Monk on May 17, 2011 at 17:35 UTC
    Here is a nice chunk of code that uses modulus to control looping:
    my ($returnNum) = 0; for my $block (@blocks) { printf ("%-15s ", $block); print "\n" unless (++$returnNum % 5); } print "\n";