Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to read the regular expression from another file?

by hippo (Bishop)
on May 07, 2015 at 09:57 UTC ( [id://1125983]=note: print w/replies, xml ) Need Help??


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

i want a perl script that reads file2 and print the lines which has any of the words listed in file1 (i.e. either a_c or b_c or c_c) and save those lines in new file.

Just on the off-chance that this isn't just a programming exercise it is worth pointing out that grep can do this already:

grep -f file1 file2 > newfile

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

    You beat me to the punch. If this is on a *nix machine, grep is FAR cleaner.

    --
    “For the Present is the point at which time touches eternity.” - CS Lewis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1125983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found