#!perl -wl use strict; my @all = qw( rsriram Corion ); my $re = sprintf '\b(?:%s)\b', join "|", map { quotemeta } @all; $re = qr/$re/; print "Searching for $re\n"; for () { chomp; if (/$re/) { print "Found at least one match in '$_'\n"; } else { print "Ignoring '$_'\n"; }; }; __DATA__ This is a line that mentions rsriram. This is a line that mentions Corion. This is a line that mentions Corion and rsriram together. This is a line that mentions neither of the two. This line intentionally left blank.