in reply to How do you move within an array using foreach?

I'm not sure whether you want your foo line or not.
But this will do for small sets.
#!/usr/bin/perl use strict; use warnings; foreach (<DATA>) { if ( /begin/ .. /end/) { if ( /begin/ ) { print "You want to skip me, yes? $_"; next; } print; next; } } __END__ 1 2 3 4 begin 6 7 end 9