Hi, you have a working solution by now, but just a few comments on some mistakes in your code, to help you progressing:
while (<F1>) { open (F3, "<new3.txt") or die; my $lines = <F3>; print F2 if (/$lines/); close (F3); }

First it is a very bad idea to open the same file repeatedly within a while loop. This is very inefficient. Whenever you have something like that, read the file with the elements to be found prior to the main loop and store these items in memory (an array, a hash, a regex, a string, something, whatever).

Second, when you read F3, you need to chomp the line to remove the trailing end of line. Else you will be looking for "c_c\n", not "c_c", so that you won't find it.

Third, this code line:

my $lines = <F3>;
is reading only one line from the file (the first one). So that if the other errors were corrected, you would still be able to catch only the first intemof the file.

Finally, this is not an error, your code will work on that, but it is considered better practice to use the so-called three-argument syntax for opening a file and to use lexical file handles:

open my $SEARCH_ITEMS, "<", "new3.txt") or die "Could not open new +3.txt $!";; my @lines = <$SEARCH_ITEMS>;
Note that I also added a message to the die statement: 1. saying what the problem is ("Could not open..."), 2. telling which file the script could not open, and 3. displaying the error message reported by the OS (the $! special variable). Believe me, this helps when you have scripts opening dozens of files.

I hope this helps.

Update: Corrected a couple of typos and added a little bit of further explanations.

Je suis Charlie.

In reply to Re: How to read the regular expression from another file? by Laurent_R
in thread How to read the regular expression from another file? by sumathigokul

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.