http://www.perlmonks.org?node_id=759648


in reply to my $1

Why do $1 and $2 behave differently than $_

Do they?

$ perl -e 'my $_ = 1' Can't use global $_ in "my" at -e line 1, near "my $_ "

Hint: use local for global/package variables instead (if you really need to...).

Or, in your case with $1 etc., I think simply creating a local copy of $1 with my $capt1 = $1; would be sufficient for your recursion problem.