Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Reading lines and matching words

by RobPayne (Chaplain)
on Apr 11, 2007 at 20:11 UTC ( #609465=note: print w/replies, xml ) Need Help??

in reply to Reading lines and matching words

You didn't specify exactly what type of matching you need, here's a very simple regex pattern match to return 1 if the line contains any one of three words. Otherwise, it returns 0.
if ($line =~ /word1|word2|word3/) { return 1; } else { return 0; }
Your code didn't show a call to a subroutine, so I'm assuming you *really* meant return. As duff said, this is what grep does.

Replies are listed 'Best First'.
Re^2: Reading lines and matching words
by mantra2006 (Hermit) on Apr 12, 2007 at 12:53 UTC
    Thank you Rob
    It worked!!!
    Thanks & Regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://609465]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2017-11-18 16:16 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.