I actually did read perlsyn. I even go back and browse it periodically for fun. I have even written code that had no purpose other than to play with features that I found there. (For instance a program that was designed as a finite state machine, switching states with "goto &foo;".) I sincerely missed this particular point. Actually I remember seeing it, and not seeing why it would be useful, then forgetting it again.

That said, unless I am missing something obvious, I find the above feature to be buggy for perl 5.005_03 on both Windows and Linux. Here is my test:

$ perl $str = <<FOO; # line 1 "foo" sub bar { die('gotcha'); } &bar(); FOO print "When executed by eval:\n"; eval($str); print $@; print "When executed by perl:\n"; open (PERL, "| perl") or die "Cannot start perl: $!"; print PERL $str; close PERL; __END__ When executed by eval: gotcha at (eval 1) line 3. When executed by perl: gotcha at foo line 2.
When I go home tonight I will try this on 5.6 and send a bug report in if I still cannot get it to work.

For the record, I consider myself a Perl hacker, not a perl hacker. (VBG)


In reply to RE: RE: RE: RE: RE: RE: Re: How to tell eval where the code is from by tilly
in thread How to tell eval where the code is from by Yaakov

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.