foreach (qw) { if (/foo(.*)bar/) { print "$1\n"; } else { print "not found in $_\n"; } }