in reply to strange thing in perl's eval function(solved))

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

#!perl -w $o = q{qq{ $& | $'}}; $p = q{.}; $_=1234; /$p/; print eval $o; __END__ 1 | 234
But this does
#!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 :)

Replies are listed 'Best First'.
Re^2: strange thing in perl's eval function (re match vars)
by a369 (Initiate) on Jun 07, 2013 at 07:42 UTC

      As choroba pointed out, this question is solved on StackOverflow

      Its a good thing this here is perlmonks, where relevant discussion is welcome :)