in reply to Code Sub-Pattern Error "Panic: top_env"

urthwrm:

/(?(?{$_ =~ |$regex (\w+ \w+)(?=\1)|})(?{s|$1||})|(?{s|$1 \w+||}))/

perlre on (?{ }):

Because Perl's regex engine is currently not re-entrant, interpolated code may not invoke the regex engine either directly with m// or s///), or indirectly with functions such as split.

Additionally, changing the string against which you are matching when you're still matching against it is just asking for trouble.