my $i = 0; foreach my $element (@array) { do_something($element) unless ($i++ % 3); }