What does this line mean in perl? -


i'm looking @ code, don't understand following line doing/checking:

return if !%foo::details:: ; 

what doing? checking existence of module foo::details?

a hash in scalar context returns false if it's empty, code returns empty list if hash %foo::details:: empty.

that hash symbol table foo::details namespace. if package variable or sub created in foo::details namespace, glob corresponding name of variable or sub created in %foo::details::. so, returns empty list if foo::details namespace empty.

$ cat >foo/details.pm package foo::details; sub boo { } 1;  $ perl -e'say %foo::details:: ?1:0;' 0  $ perl -e'use foo::details; %foo::details:: ?1:0;' 1 

it might trying check if foo::details module has been loaded, it's not perfect. example, think foo::details has been loaded if foo::details::bar has been loaded. check if foo::details has been loaded, might better check if $inc{"foo/details.pm"} true. problem approach won't find "inlined modules".


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -