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

1. Use a flag. 2. If you read a file as you mentioned, do not use arrays at all:

open my $fh,'<', $filename or die $!; my $flag; while( <$fh> ){ unless( $flag ){ next unless /^start_mark/; $flag = 1; } elsif( /^end_mark/ ){ $flag = 0; } } continue { print if $flag } close $fh;
--
http://fruiture.de