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 :)


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.