It won't any more, I made the minimal correction that solved this and I hope you will apologize me for not having pointed out explicitly having done so (but it's really a one-char correction).

Incidentally, to be fair I'm not really sure if with input strings limited to 20 chars (as of the rules!!) you can have more than 10 nested parens and thinking about it one more second... no, you can't!

And then you didn't fix the other \d. Now it still fails on "10b". Yes, I know the rules are for people who can't program and uses arbitrary limits to allow even the most sloppy coders to score a few marks. But that's no excuse for code on perlmonks, is it? ;-)

But then the rules explicitly state that "any numbers will be between 2 and 9 inclusive".

Yes, I know the rules are for people who can't program and uses arbitrary limits to allow even the most sloppy coders to score a few marks. But that's no excuse for code on perlmonks, is it? ;-)

Personally I do not share this somewhat elitarist attitude. (Hey, at least that's how I perceive it to be!)

Also, one should take into account that not everybody is so lucky as to use perl, as we do! I don't dare to imagine how damned complicate it would be to do this, say, in C... (well, it would, for me!)

Last, I think that it was important to give the OP an answer to what he asked for, i.e. a solution to the proposed problem. Please note, in particular, that I clearly wrote: "sample code to solve the assignment". But of course on PM it's fine to give solutions that also do more than that...