Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2016-10-21 10:08 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (288 votes). Check out past polls.