my @targ_strings = ; chomp @targ_strings; my $targ_regex = join "|", @targs; while () { if ( /;(?:$targ_regex);/ ) { print OUT; } else { print ERR; } }