I can of course work with this limitation, but it's not completely satisfying since it was not necessary before (don't remember version of perl, 5+years ago)
That's not true. Variable declarations have always taken effect in the statement following the one containing the declaration. Perhaps you weren't using lexical ("my") variables (or strict) "5+ years ago".
Unrelated, don't use lexicals from outside the pattern inside of (?{ ... }), (??{ ... }) and anything similar.
$ perl -wE' sub f { my $x = $_[0]; "" =~ /(??{ say $x; "" })/; } f("abc"); f("def"); ' Variable "$x" will not stay shared at (re_eval 1) line 1. abc abc
Use a package variable instead.
$ perl -wE' sub f { local our $x = $_[0]; "" =~ /(??{ say $x; "" })/; } f("abc"); f("def"); ' abc def
In reply to Re: (??{ code }) versus (?PARNO) for recursive regular expressions
by ikegami
in thread (??{ code }) versus (?PARNO) for recursive regular expressions
by wind
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |