#!/usr/bin/perl -w use strict; my $text = "Mr. X is a bozo and was hired and then resigned."; #build an "OR" regex from a list of search words #add \b (boundary) in front and back, then | between my @search_words = qw(bozo hired resigned); @search_words = map{"\\b$_\\b";}@search_words; my $search_regex = join("|",@search_words); #print "search_regex is: $search_regex\n"; #debug my %matched = map{$_=>1}($text =~ m/$search_regex/gi); #match global print "This bozo resigned - thank goodness!" if ($matched{bozo} and $matched{resigned}); #prints: This bozo resigned - thank goodness!