http://www.perlmonks.org?node_id=609465


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
    Sridhar