use strict; use warnings; $string = "hello there"; if ( $string =~ /[0-9]/ ) { print "'$string' has a digit.\n"; } else { print "'$string' has no digit.\n"; } $string = "this one has a 2"; if ( $string =~ /[0-9]/ ) { print "'$string' has a digit.\n"; } else { print "'$string' has no digit.\n"; }