An example exporting module:
package MyNameSpace::Faction; ... BEGIN { #use Exporter 'import'; use Exporter qw (import); #@MyNameSpace::Faction::ISA = qw(MyNameSpace::Player Exporter); #@MyNameSpace::Faction::ISA = qw(Exporter MyNameSpace::Player); @MyNameSpace::Faction::ISA = qw(MyNameSpace::Player); @MyNameSpace::Faction::EXPORT_OK = qw( &get_faction &max_faction ); }
(As you can see from the commented-out lines, I've tried several syntactic variations for calling Exporter, but they haven't made any difference.)
Calling module 1:
package MyNameSpace::Player; ... use MyNameSpace::Faction qw (get_faction); ... $self->{faction} = get_faction($faction);
This produces Undefined subroutine &MyNameSpace::Player::get_faction called at [the last line included above] when I try to use the module.
Calling module 2:
package MyNameSpace::Territory; ... use MyNameSpace::Faction qw (get_faction); ... $self->{faction} = get_faction($faction);
This works perfectly fine.
Both reference the same package and import it with identical use statements, yet one successfully imports get_faction and the other doesn't. How do I track this down and resolve it? I know I can work around it by changing the failing line to $self->{faction} = MyNameSpace::Faction::get_faction($faction);, but that neither explains nor resolves the inconsistency of why Territory imports get_faction and Player doesn't.
(This may not be the best example, as it looks a little circular (Faction isa Player and exports the function that Player fails to import), but I've run into similar issues between otherwise unrelated modules, so I'm fairly sure that circularity isn't the cause. This example is just the one I recently encountered and finally drove me to ask about it.)
In reply to EXPORT_OKed function refusing to import by dsheroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |