if ($string =~ s/(\d)//) { my $digit = $1; ... } else { print "No digit in '$string'\n"; }