$num = $1 if length($string) == 7 and $string =~ /^\s*(\d+)$/;