in reply to Question on pattern matching

If you want get match only in digits, to solve your problem write so: if ($my_dat =~ /^0-9$/ ) {some code here;} or if ($my_dat =~ /^\d+$/ ) {some code here;}