in reply to Length of first captured match

local our $length; $x =~ /(\d+)(?{ $length = length($1) })$/;

or in Perl 5.8:

local our $length; $x =~ /(\d+)(?{ $length = length($^N) })$/;