Its because $' and $& are magic, and come with a performance penalty, and in general you shouldn't use them
Also, you shouldn't use them without testing for sucess, without writing if ( $line=~/$pattern/ ){ ... }
Change my $output= q{" $& | $'"}; and you'll get
Use of uninitialized value $& in concatenation (.) or string at (eval +1) line 1, <DATA> line 1. Use of uninitialized value $' in concatenation (.) or string at (eval +1) line 1, <DATA> line 1.
Add local $&; on top of your program, that is mention $& in your code, and the penalty kicks in and the warning goes away
Also, there might be a bug in there too, for example this doesn't trigger this warning
But this does#!perl -w $o = q{qq{ $& | $'}}; $p = q{.}; $_=1234; /$p/; print eval $o; __END__ 1 | 234
#!perl -w $o = q{qq{ $& | $'}}; $p = q{2}; $_=1234; /$p/; print eval $o; /$p/; print eval $o; __END__ Use of uninitialized value $& in concatenation (.) or string at (eval +1) line 1. Use of uninitialized value $' in concatenation (.) or string at (eval +1) line 1. | 2 | 34
On a scale of importance from 1 to 10, I'd rate this bug a -3000 :)
In reply to Re: strange thing in perl's eval function (re match vars)
by Anonymous Monk
in thread strange thing in perl's eval function(solved))
by a369
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |