if ($my_dat !~ /^\d{2}$/) { # some code here }