my $what = "(fred|barney){3}"; while (<>) { chomp; if ($_ =~ $what) { print "It's in there.\n"; } else { print "Not there.\n"; } }