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!


Perl is environmentally friendly - it saves trees

In reply to Re^3: Search and Replace for XML by GrandFather
in thread Search and Replace for XML by srprabu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.