Yes, this error message sucks. It should list the two possible explanations with the most likely ("no such method") stressed more than the other ("*.al file missing because module not properly installed").

Note that this error message is a result of over-use of inheritance. In particular, this line from DBI.pm:

@ISA = qw(Exporter DynaLoader);

means that DBI "is a" Export and "is a" DynaLoader. Which means that if either Exporter or DynaLoad "is a" SomethingElse, then DBI also "is a" SomethingElse.

So some implementation detail of Exporter or DynaLoader becomes the baggage of DBI because it declares itself to be a descendant of them. In this case, the detail is that one (or both) of them "is a" AutoLoader (or similar). So DBI suddenly acts like an AutoLoader even though it had no desire to do so.

It would be better if Exporter and DynaLoader didn't use inheritance to get the AutoLoader functionality. And it would be better if DBI didn't use inheritance to get Exporter nor DynaLoader functionality.

Note that this realization has lead to Exporter now supporting better ways for it to be used, such as:

use Exporter qw( import );

And note that some module authors have realized this problem with DynaLoader and worked around it similarly:

require DynaLoader; # ... DynaLoader::bootstrap( __PACKAGE__ );

It is rather sad that the OO mindset so often jumps to inheritance as the answer for nearly every problem. Here we have two important core modules that mostly just need to provide one subroutine to the modules that use them, yet they encourage inheritance to be used to accomplish this.

It would be nice if DBI would fix this. Since DBI tries to be quite portable, it probably can't assume a modern version of Exporter, so it should instead use something like this:

BEGIN { require Exporter; *import= \&Exporter::import; }

Thus DBI would no longer produce this particularly misleading error message.

- tye        


In reply to Re^2: What is the /auto/ directory used for? (inheritance--) by tye
in thread What is the /auto/ directory used for? by nmerriweather

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.