note
rjt
<p>The problem you want to solve is certainly solvable. However, the approach you want to take is going to be very ugly, if it's even possible at all. Here's what I would do instead:</p>
<c>s/(\d)//;
say for (split /\n/)[0..$1-1];
</c>
<p>However, you haven't mentioned what context this is in, and the data does seem highly contrived. What problem are you really trying to solve?</p>
<p>If you need to match an expression like this several times in a larger chunk of text, you'll need to split that text somehow, but you haven't given enough information for me to help you, there. (For example, <c>split /(\d)/</c> first would give you an array of digits and strings to loop over.)</p>
1047667
1047667