Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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.


Comment on Re: Reading lines and matching words
Download Code
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
    Sridhar

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-07-29 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls