in reply to Don't know how to resolve

Try this one:
if($d =~ m/^\d{6}$/) { print "Exact match\n"; }