为什么这颗炸弹
perl -e 'print qr{$_(??{$_})}'
虽然这两者是分开工作的:
perl -e 'print qr{$_}'
perl -e 'print qr{(??{$_})}'
错误信息是
Eval-group not allowed at runtime, use re 'eval' in regex m/(??{$_})/ at -e line 1.
真的,我应该升级 Perl 吗?我有5.14.4。
最佳答案
这是 5.18.0
中修复的错误和5.17.1
。
The implementation of code blocks in regular expressions, such as (?{}) and (??{}), has been heavily reworked to eliminate a whole slew of bugs. The main user-visible changes are:
Code blocks within patterns are now parsed in the same pass as the surrounding code;
Lexical variables are now sane as regards scope, recursion and closure behavior.
关于regex - 为什么我不能连接在 qr 下编译和运行时评估的模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19551918/