In one project, I compile a lot of code (in AUTOLOAD) from a data base. When such a compiled function gets into trouble, the error message would read like:
Use of uninitialized value at (eval 137) line 24
Because I don't know in what order the functions are defined, this is much less useful than a message like:
Use of uninitialized value at (method P::foo) line 24

Is there a proper way to tell eval the origin of the code (in our case the string "Method P::foo") that the messages come out correctly?

At the moment, I hack the source of perl: I found the line where a buffer is set up with the string "_<(eval %l)". I added some code to check whether the perl variable $CB::EvalName is defined and true. If yes, it replaces the buffer (and comes out correctly). If no, then the buffer is used as normal.

It works fine but it doesn't look right...


In reply to 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.