Who doesn't like
perl -w and
use warnings; and
use strict; and
perl -MO=Lint,-all myprog.pl? However, I just had a simple problem in OO coding style that I wish had been caught. As I am writing this, I think it may not be an OO thing as much as a module/package thing.
My problem was this: I mispelled a class. More specif., I mispelled an exception class after an eval. For example:
eval { $obj->method() };
if ($@) {
if (my $exception = My::Excpetion::Thingy->caught()) {
do_something();
} else {
do_the_other_thing();
}
}
You see,
My::Exception::Thingy was being caught, but my code was executing
do_the_other_thing(); because I mispelled "Exception" in my
->caught().
My big picture questions are these. I am guessing that B::Lint would have to be aware of Exception::Class class definition syntax to catch this. If I wanted Lint to help me with Object::InsideOut syntax that situtation would be the same. Has stuff of this nature already been completed? My CPAN and Google searches haven't yielded anything. Is there some other easier way that I'm missing? If there is no easy answer, does Perl 6 offer an improvement?
I guess the essential nitty-gritty thing is: when using Perl OO, am I stuck catching typos as runtime bugs?
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.