in reply to Print only the matched line when process line by line from a file

So the question is how to put more than one condition into the initial if()?

if (/Grapes/ || /strawberry/i) { print; } else { print "$_ is not in the list.\n"; }

Or in this case you could leverage the power of alternation within the regular expression:

if (/Grapes|(?i:strawberry)/) { .... } else { .... }

If the behavior is supposed to differ based on what matched, you could also do this:

if(/foo/) { # do something } elsif (/bar/) { # do something else } else { # complain about falling through }

Dave