Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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 romping around the Monastery: (8)
As of 2018-07-16 03:31 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (330 votes). Check out past polls.