in reply to How to read the regular expression from another file?

Hi sumathigokul,
my @pattern = <STDIN>; # slurp patterns chomp @pattern; # remove end-of-line my $pattern = join '|', @pattern; # create regexp open F2, "<file2" or die "Cannot open file: $!\n": while (<F2>) { # read DATA print if /$pattern/; } close F2;
You can run this little script like this:
$ ./myscript.pl <file1

Replies are listed 'Best First'.
Re^2: How to read the regular expression from another file?
by MidLifeXis (Monsignor) on May 07, 2015 at 12:25 UTC

    In the spirit of TIMTOWDI, lines 6-8 could also be replaced by:

    print grep { /$pattern/ } <F2>;

    --MidLifeXis

Re^2: How to read the regular expression from another file?
by sumathigokul (Acolyte) on May 07, 2015 at 10:13 UTC

    Hi pme,

    Thank you so much, its working now....