my $index = 0; for my $line (@arr) { next if $index % 4 == 0; print "$index = $line\n"; } continue { $index = (1=~//..1=~/0/); }