in reply to use strict (upper or lower case)

use Strict; is a rather complex no-op. It does nothing of consequence (other than confuse people reading your code into thinking it might do something).

use strict; gives you lots of errors because that is what it is supposed to do. See strict.pm for a little discussion about why you might want to have all of these errors generated. The basic idea is that use strict makes it more likely that you'll find a mistake early and thus save you a lot of time. But using it requires a few basic changes to the way you write scripts (you have to declare your variables so it can tell when you mispel a variable name, for example).

As already mentioned, the reason "use Strict;" does nothing silently is partly because Win32 file systems ignored the case of letters in file names. Well, that is part of the reason. The other part of the reason is that Perl (stupidly, IMO) doesn't complain when you include a module via one name but that module doesn't actually go by the name you gave.

You can run into the same problem quite a few other ways. For example, you might try to install Bogon::Quartz for your web page where you don't have "shell" access so you put the Quartz.pm file on the server and figure out that use Quartz; doesn't complain about anything and then you can't figure out why this module doesn't work like the documentation says it should. Perl should really tell you that use Quartz; did not find any module called "Quartz" even though it found a Quartz.pm file. There are even more ways to run into this problem if you are working on writing a module yourself.

So, in the end, it would be really nice if UNIVERSAL::import() complained when you used a module that didn't match the namespace you requested. You might find Universally unimportant and overused useful (and important).

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

Replies are listed 'Best First'.
Re: (tye)Re: use strict (upper or lower case)
by chromatic (Archbishop) on Aug 16, 2002 at 17:44 UTC

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

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