|The stupid question is the question not asked|
Namespace and use confusion. "Undefined subroutine errors"by Wonko the sane (Deacon)
|on May 05, 2005 at 19:18 UTC||Need Help??|
Wonko the sane has asked for the
wisdom of the Perl Monks concerning the following question:
Recently I came across a problem with namespaces that I do not fully understand.
I was under the assumption that the same module could be 'used' or required
AB_prod.pm => SYS_mail.pm => AB_prod.pm
I am finding though, that this kind of setup causes problems in some situations,
When modules are used in a certain order, I start getting runtime error messages like this one.
Here is an simple test setup that I have made up to show what I am talking about....
In this hypothetical example, the modules used by the Application areAny help is much apprecited,
divided up into layers. Each set of layer modules is kept in its own directory.
/u/web/wonko/test/lib/AB/ -- Contains Applied Business rules.
This module 'uses' the SYS_mail module, just as the test1.pl script does. This in itself does not seem to be a problem.
Here is where the problem develops.
This module uses the'AB_prod.pm' module, which is already using the 'SYS_mail.pm'
'AB_prod' => 'SYS_mail' => 'AB_prod'. This causes a situation where
it looks like the namespace is being modified to where the AB_prod module
cannot find the SYS_mail module again, during runtime.
This situation does not generate any errors and passes fine under a
'perl -cw'. The error only surfaces, when the actual function(SYS_mail::send_mail)
is called at runtime.
It like its entry in the Symbol table got stomped or something.
When the test1.pl script is run, the following runtime error is generated.
Notice that it appears to be looking for the send_mail function in
What is very strange, is that changing the order of the AB and SYS use
Is the Symbol table entry for this function actually getting squashed?
Is this type of setup for Modules just unacceptable?