chomp(my @words = @bpl); my $pattern = join '|', @words; #my @lines; my $item; while (@bpout) { my $item = (@bpout); push $item, $_ if /$pattern/; } print "$_\n" foreach $item;