in reply to (tye)Re: use strict (upper or lower case)
in thread use strict (upper or lower case)

What would this version of UNIVERSAL::import() do when it encountered a module that defined and inherited no import()?

  • Comment on Re: (tye)Re: use strict (upper or lower case)

Replies are listed 'Best First'.
(tye)Re2: use strict (upper or lower case)
by tye (Sage) on Aug 16, 2002 at 19:49 UTC

    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")