$match = '(foo|baz|bar)'; while () { next if ($_ !~ /$match/o); }