in reply to /ee -> Use of uninitialized value in substitution iterator (without back references)
As per Regexp Quote Like Operators, /ee means "Evaluate the right side as a string then eval the result." and "A /e will cause the replacement portion to be treated as a full-fledged Perl expression and evaluated right then and there. It is, however, syntax checked at compile-time. A second e modifier will cause the replacement portion to be evaled before being run as a Perl expression."
So basically, "$rhs" becomes qqq, which when evaled causes an error: Try adding print $@ to your code and you'll see Bareword "qqq" not allowed while "strict subs" in use at (eval 1) line 1., so eval is returning undef which is causing the Use of uninitialized value in substitution iterator.
Running perl -e 'print eval("qqq");' prints qqq.
That's because that's not using strict - perl -wMstrict -e 'print eval("qqq"); print $@;' prints Bareword "qqq" not allowed while "strict subs" in use at (eval 1) line 1.
And of course there's no warning with just /e instead of /ee; in the real program, I need /ee.
Perhaps your example is a little too abstracted from the original program? Needing /ee is somewhat rare in my experience. Could you show a more representative example of why you (think you) need it, perhaps we can come up with a better solution?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: /ee -> Use of uninitialized value in substitution iterator (without back references)
by karlberry (Sexton) on Apr 29, 2021 at 17:50 UTC | |
by haukex (Archbishop) on Apr 29, 2021 at 18:11 UTC |