A hash in a scalar context returns false if it is empty, so your code returns an empty list if the hash %Foo::Details:: empty.
This hash is a character table for the Foo::Details namespace. If a batch variable or subfolder is created in the Foo::Details namespace, a globe will be created in %Foo::Details:: that matches the name of the variable or sub. Thus, it returns an empty list if the Foo :: Details namespace is empty.
$ cat >Foo/Details.pm package Foo::Details; sub boo { } 1; $ perl -E'say %Foo::Details:: ?1:0;' 0 $ perl -E'use Foo::Details; say %Foo::Details:: ?1:0;' 1
You might be trying to check if the Foo :: Details module is loaded, but it is not perfect. For example, he will think that Foo :: Details is loaded, even if only Foo :: Details :: Bar is loaded. To check if Foo :: Details has been loaded, it is better to check if $INC{"Foo/Details.pm"} . The problem with this approach is that it will not find "built-in modules."
source share