open my $bpl_fh, '<', '/tmp/bpl.txt' or die $!; chomp(my @words = <$bpl_fh>); close $bplist_fh; my $pattern = join '|', @words; my @lines; open my $fh, '<', '/tmp/lst.txt' or die "unable to open file '$file' for reading : $!"; open my $fh2, '>', '/tmp/lst2a.txt' or die "unable to open file '$file' for reading : $!"; while (<$fh>) { push @lines, $_ if /$pattern/; } print $fh2 "$_\n" foreach @lines; close $fh2; #### 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;