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:
say for (split /\n/)[0..$1-1];
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?
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, split /(\d)/ first would give you an array of digits and strings to loop over.)