How about you show us a very small sample data set and the code you are having trouble with along with the output you get and the output you expect.
Note that for small samples it is convenient to use strings as the input files and to print output. Consider:
use strict; use warnings; my $fileA = <<FILEA; Thank you for considering me. Let me tell you straight, there are two file a.txt and b.txt. I want each line of text in a.txt should be searched FILEA my $fileB = <<FILEB; txt FILEB my @words; open my $bIn, '<', \$fileB or die "Open fileB failed: $!"; while (<$bIn>) { chomp; push @words, $_; } close $bIn; my $match = join '|', @words; open my $aIn, '<', \$fileA or die "Open fileA failed: $!"; while (<$aIn>) { next unless /\b($match)\b/; print; } close $aIn;
Prints:
Let me tell you straight, there are two file a.txt and b.txt. I want each line of text in a.txt should be searched
which reads a "file" containing a list of words - one per line, then prints lines from a second "file" that contain any word from the list. Not the job you want to do I know, but I can't yet tell what it is that you do want to do!
In reply to Re^3: Search and Replace for XML
by GrandFather
in thread Search and Replace for XML
by srprabu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |