Ok. I don't think
exit is right for me; I am writing a module and would like the code which uses it to have the option to trap it with eval.
The gist of the module is a series of pushes onto a stack, which then get sent to a DB upon request. The send-to-DB is an explicit call. I've got a DESTROY that checks the stack is empty (either never was pushed, or was pushed but then properly sent off to DB) when the object goes out of scope.
I want the DESTROY do something like this
# untested
sub DESTROY {
my ($self) = @_;
die "destroy called with non-empty stack" if $self->stack_count;
}
Now, the caller could trap this die if they knew what they were doing, or if they didn't, they'd get a fatal die if they used the module improperly (eg not calling send-to-DB).
So that's what I want to do:
die from a DESTROY in such a way isn't caught by the DESTROY itself, but could be caught (eg eval) by a module user.
Do I have any shot at getting this behavior?
water
}
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.