in reply to Using previous match in the same matching regexp

If you need a solution that doesn't clobber $string:
$substr = $string =~ /^(\d+) (.*)/ && substr($2, 0, $1);
If you need both $len and $substring:
($len, $substr) = $string =~ /^(\d+) (.*)/ && ($1, substr($2, 0, $1));