Perl match outside “if” doesn't reset $1 on loop

后端 未结 1 1816
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 14:12

I am working on patching the Zoidberg Perl shell to fix some errors that modern Perl versions throw when testing. Note, I am not the original author nor am I criticizing him

相关标签:
1条回答
  • 2020-12-06 14:40

    From perlre:

    NOTE: Failed matches in Perl do not reset the match variables, which makes it easier to write code that tests for a series of more specific cases and remembers the best match.

    But you're right, Test A did work like the other two in 5.8.9. I can't find anything in the 5.10.0 release notes that explains it, but there were numerous RE changes in 5.10, and one of them must have affected this. I don't think the 5.8 behavior was ever intended.

    0 讨论(0)
提交回复
热议问题