foreach (grep /start/ .. /stop/, @data){ next if /start/; last if /stop/; # do stuff }