Re: Obscure baffling "module not exported" error: can someone help me find the cause?



Henry Law wrote:
I have a bizarre problem with packages and I'm hoping that someone can help me find out what I'm doing wrong because I'm utterly stumped.

The error is "not exported" for something that quite clearly is exported (details follow). The error disappears when one of several particular
<snip>

There are three modules: NFBT::ServerLib, NFBT::Utilities::Common and NFBT::Utilities::Server. There is some requirement in them for subroutines out of one or more of the others.
You appear to have circular dependencies between these modules, and I'd guess that the mutual importing is confusing the import/export mechanism.

There is a brief discussion at

http://www.perlmonks.org/?node_id=473692

I'd try breaking the circular dependencies for a start.



package NFBT::ServerLib;
<snip>
sub write_xml_twig {
# The original write_xml_twig required several subroutines from
# Utilities::Common and also 'shadow_conv'
# Comment either of these out, problem disappears
use NFBT::Utilities::Common ":all";
use NFBT::Utilities::Server qw(shadow_conv); # "not exported" error here
print "This is write_xml_twig in package NFBT::ServerLib\n";
}

This is an unrelated issue, but "use"ing happens at compile-time. Putting the use statement inside the subroutine does not limit its scope or control when it is executed. perldoc -f use has the gory details.

Mark
.