The problem with anonymous subs is that it still messes up caller() information and will display the line where the sub was defined as the error source. And rebuilding the behavior with prototypes leaves me basically with the same problem.
I had a look at the source of Carp to see how it deals with that, and it seems that most of the (evil) magic comes from goto jumps and tracking the callers package name to exclude calls from those that are considered 'internal' (i.e. Carp itself).
And since this all has already been invented, written and debugged, I'll go back to loading Carp and referencing to either carp() or croak() (which works as intended).
Thinking about it, I'd guess that core functions 'live' in a different memory space than functions and variables generated on compile / run. So it probably makes good sense that you can't take a reference to them.
It's just a bit 'disappointing' to run into some kind of limit in a language that seems to have none ;)
Thanks alot for the replies!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.