in reply to Re^4: error for undefined function that's been imported
in thread error for undefined function that's been imported
The explanation: when you "use Fred", and Fred.pm exports symbols, these only go into the namespace which is current when you issue "use Fred". They don't go to all namespaces. Consider the following:
package Hunting::Snark; use Bellman qw(foo bar); # Bellman's exported symbols go into namespace Hunting::Snark # hence &Hunting::Snark::foo is aliased to &Bellman::foo package Boojum; foo(); # is an undefined subroutine. There is no &Boojum::foo
Why I was mentioning that you need to declare a package first before you use things, is that otherwise, any exports will go into main:: not where you want them to. If you declare the package first and immediately above, Exporter will put the symbols into the namespace of the package just declared.
In terms of fixing your problem, you can add another use statement in the new namespace. This won't re-read the module as it has already been flagged as having been loaded, but the use will redo the Exporter functionality.
... package Boojum; use Bellman qw(foo bar); foo(); # &Boojum::foo is now defined. aliased to &Bellman::foo
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: error for undefined function that's been imported
by argv (Pilgrim) on Aug 16, 2005 at 05:11 UTC | |
by rinceWind (Monsignor) on Aug 16, 2005 at 20:24 UTC | |
by argv (Pilgrim) on Aug 17, 2005 at 07:24 UTC |