$ perl -le'do { print $i++; last if $i>5 } for (1..10); print "end"' 0 1 2 3 4 5 end