foreach my $line (@lines) { next if $line =~ /^QKC_/; #do something with $line } #### @subset = grep(/^QKC_/, @lines);