Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl doesn't give error when module is not found 2

by Jenda (Abbot)
on Mar 27, 2024 at 10:52 UTC ( [id://11158527]=note: print w/replies, xml ) Need Help??


in reply to Perl doesn't give error when module is not found 2

  1. If module A uses something from module B, then there OUGHT TO BE use B; inside A.pm. Fullstop. Modules should not expect someone else to load their dependencies for them. There is no need to "optimize" and use a module just one. Perl is clever enough to notice the module had already been loaded and it doesn't load it twice.
    The second time Perl only calls the module's import() subroutine to allow it to export the default list of functions into the calling namespace.
  2. You are NOT supposed to run modules directly. Very few modules support that and likely even fewer should.
  3. Modules and namespaces are related, but they are NOT the same thing. You can have several namespaces right inside your a.pl script and define the myModule2:authorize right there. It's actually quite common for modules to contain several namespaces. One of them SHOULD match the name of the file, but there's often several others inside.

Jenda
1984 was supposed to be a warning,
not a manual!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2025-11-07 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.