foreach (@data){ next unless $check = /start/ .. /stop/; next if $check == '1' or $check =~ /E/; # do stuff }