hi monks,
I'm currently making my first steps in OO-Perl-Coding and couldn't find an answer to the following problem yet:
Some simple code-example:
test.pm:
...
sub status {
my $self = shift;
if ($self ne 'hm') {
$! = '2';
return undef;
}
}
...
test.pl
$obj->status() || die "Error: $!";
So what I'd like to do is to modify the $!-Var but not just with a number like done in the code above, but also the error-msgs itself with my own text. Is there a clear/common way to do that, and would you suggest to do so if there is?
I've had a look at some modules like like ftp.pm but all I could find were simple "return undef;" so that the caller could do the die itself but won't get a error-message, or a croak in the module so that the caller would also die even if the one who uses it maybe don't want his. I know that I could use eval in the caller but I'm wondering if there issn't a more easy way to do handle this...
giant
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.