If you follow the link I gave, you'll find code that includes:     die "$pack->import() called for empty package!\n" Tho, the test isn't simply "doesn't define import()". Note that 'die' should probably be 'croak' and the '!' isn't necessary. (:

The linked-to code assumes you are on Win32 and so jumps right into looking for a simple letter case mismatch. That'd be very nice to keep but it might be good to make it not look for letter case mismatch on operating systems that don't typically ignore case in their file systems (then again, maybe not).

And, of course, there'd be a perldiag entry that explains other common ways this mistake happens. (I already described two of the big three, the third one being that you simply got your "package" statement wrong in the module you are writing.)

To get this into the Perl core, there should probably be an XS version of UNIVERSAL::import that does "require UNIVERSAL" to replace itself the first time it gets called.

        - tye (but my friends call me "Tye")

In reply to (tye)Re2: use strict (upper or lower case) by tye
in thread use strict (upper or lower case) by Anonymous Monk

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.