#% is the modulo operator so it's switching back and forth between even and odd numbers $|++; $\="\n"; for (my $i=0; $i < 100; $i++){ if ($i % 2){ print STDERR $i; } else {print $i;} }