$var = 'bat'; if ($var =~ /^[bat]{3}$/) { print "match"; } else { print "fail"; }