Subject: | App::use not always loading modules |
App.pm’s use subroutine has some faulty logic in it:
sub use {
&App::sub_entry if ($App::trace);
my ($self, $class) = @_;
no strict; # allow fiddling with the symbol table
if (! defined $used{$class}) {
# if we try to use() it again, we won't get an exception
$used{$class} = 1;
# I could look for a particular variable like $VERSION,
# local (*VERSION) = ${*{"$class\::"}}{VERSION};
# print "$class VERSION: ", ${*VERSION{SCALAR}}, "\n";
# but I decided to look for *any* symbol table entry instead.
if (%{*{"$class\::"}}) { # if any symbols exist in the symbol table
# do nothing
}
The problem here is that even compiling code like ++$Data::Dumper::Useqq is enough to
autovivify the *Useqq glob in %Data::Dumper::. So this logic in App::use can easily be fooled.
It fails its own tests in perl 5.15.4 for that reason. Why don’t you just use %INC?
Untested:
(my $class_path = "$class.pm") =~ s|::|/|g;
if (exists $INC{$class_path}) {
# do nothing
}