Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: use statement seemingly ignored

by ikegami (Patriarch)
on Nov 15, 2022 at 21:12 UTC ( #11148193=note: print w/replies, xml ) Need Help??

in reply to use statement seemingly ignored

Why is it trying to call a local version of that sub instead of finding in the exported routines included in the use statement.

Importing a sub literally places it in the importing namespace. So if getMeetInfo had been imported into NCPS::Results, it would be found at NCPS::Results::getMeetInfo.

I suspect you have modules that directly or indirectly import each other, and that this is the cause of the problem.

Replies are listed 'Best First'.
Re^2: use statement seemingly ignored
by BillKSmith (Monsignor) on Nov 18, 2022 at 21:18 UTC
    The OP tells us that he tried the workaround of using the fully qualified name in the call and got the same error message. Does this not tell us that the function is not only not imported, but not even defined (at least not at the time it is called)? His conclusion that his use statement was ignored is at least reasonable. I suspect that you are right about the modules using each other. The documentation Perl Modules recommends require rather than use in this case. Can you explain?

      Does this not tell us that the function is not only not imported, but not even defined

      The error message from the OP tells us it wasn't defined.

      Neither the error message or the fact that using the full qualified name works tells us whether it was imported or not.

      But it does strongly suggest the problem is that it wasn't imported, yes. The two most likely causes of that is buggy/missing exporting logic, or modules that (directly or indirectly) use each other.

        I seem to have been a bit careless in my use of the word 'defined'. The original error message tells us that the function 'getMeetInfo' was not defined in the namespace NCPS::Results. This means that it was not successfully imported from the module NCPS::Meets. The [almost] same error message from the workaround with the fully qualified name tells us that the function is not even defined in own namespace. There is no function to import. (It is unlikely that the NCPS::Meets module is even loaded.) We should look for the error in the way modules are loaded, before even considering the way functions are imported. The existing maze of nested BEGIN blocks is probably an incorrect attempt to allow modules to use each other.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148193]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2023-09-30 23:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found