Re: Obscure baffling "module not exported" error: can someone help me find the cause?
- From: "attn.steven.kuo@xxxxxxxxx" <attn.steven.kuo@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 13:28:34 -0800 (PST)
On Jan 31, 12:20 pm, Henry Law <n...@xxxxxxxxxxxxx> wrote:
(snipped)
Now for the description of the code itself, which is a bit involved,
despite my having condensed it down to its bare essentials. If you're
prepared to help me make sense of this thenhttp://www.lawshouse.org/perl/Problem.jpgshows the thing
diagrammatically, with arrows drawn on. You can just about read the code
in the image too.
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.
(snipped)
First of all, you have a couple of modules that mutually use
each other, namely:
NFBT::ServerLib and
NFBT::Utilities::Server
this is generally a bad idea and you should consider refactoring;
see the discussion here:
http://www.perl.com/pub/a/2000/07/p5pdigest/THISWEEK-20000709.html#Mutual_use
Remember that use statements are collected into the BEGIN block (even
if
you embed them inside a subroutine) to be evaluated at compile-time
-- see 'perldoc perlmod'.
So, I'd suggest that you refactor. A quick "work-around" would be
that
in NFBT::Utilities::Server, you change
use NFBT::ServerLib
to
require NFBT::ServerLib;
import ServerLib (qw/write_xml_twig/);
in which case:
#!/usr/bin/perl
use strict;
use warnings;
use NFBT::Utilities::Server qw ( shadow_conv );
print "This is the test routine $0\n";
shadow_conv();
ought to run as expected (because 'require', unlike 'use'
is evaluated at run-time).
--
Hope this helps,
Steven
.
- References:
- Prev by Date: Re: Obscure baffling "module not exported" error: can someone help me find the cause?
- Next by Date: Re: How would I create a Regular Expression to check
- Previous by thread: Re: Obscure baffling "module not exported" error: can someone help me find the cause?
- Index(es):