in reply to Calculating variable {n} in regex match
$num='36737'; $idx=0; while($num=~m/[0-9]{$idx}/) { $idx++; } $idx--; # adjusment to get correct answer print "\n$num has $idx digits "; [download]
Is this what you wanted?