http://qs321.pair.com?node_id=302977


in reply to Windows pitfall: Subroutine redefined with use Modul

yes, this is a nasty one indeed. as we all know, Perl is case sensitive, but the Windows filesystem not. what happens here is that Perl stores information about the modules it has loaded in its %INC hash, and it ends up having two entries for Subclass1. if you add these lines at the end of the bla.pl script:
use Data::Dumper; print Dumper(\%INC);
you'll see something like:
$VAR1 = { [...] 'subclass1.pm' => 'subclass1.pm', [...] 'Subclass1.pm' => 'Subclass1.pm', [...] };
so, the file is one but Perl sees (and loads) two modules. this could also pose serious problems with imported symbols, because when the case of the package name doesn't match, Perl loads the .pm file but doesn't export anything, as in:
use fIlE::SpEc qw(catfile); # note the wrong case $x = File::Spec->catfile('a', 'b', 'c'); # this works $x = catfile('a', 'b', 'c'); # this croaks
this is even more unobvious, because the error goes unnoticed until you try to use something that's exported from the module.

unfortunately, Perl can't possibly catch this sort of errors, so you have to watch your case. one possible solution (for the typo-prone individuals :-) could be to always cut & paste the use line from the SYNOPSIS found in the module documentation.

cheers,
Aldo

King of Laziness, Wizard of Impatience, Lord of Hubris