Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: loading modules at runtime

by ikegami (Patriarch)
on Oct 14, 2006 at 21:08 UTC ( [id://578321]=note: print w/replies, xml ) Need Help??


in reply to Re^2: loading modules at runtime
in thread loading modules at runtime

Module might not have an import.

Module->import( PARAMETERS ) if Module->can('import');

This is rather moot, since once usually wants to avoid importing from a dynamically loaded module.

Replies are listed 'Best First'.
Re^4: loading modules at runtime
by chromatic (Archbishop) on Oct 15, 2006 at 04:07 UTC
    Module might not have an import.

    There's one in UNIVERSAL, if anything has loaded that. Besides:

    # in NoImport.pm package NoImport; 1; # in no_import.pl use strict; use warnings; require NoImport; NoImport->import();
Re^4: loading modules at runtime
by Corion (Patriarch) on Oct 14, 2006 at 23:17 UTC

    But the import routine might also do other things than setting up symbols in the calling namespace - it might set up internal data corresponding to the namespace. So it doesn't hurt to call import, or at least to read the documentation of the imported module to see what it actually does.

      use Module (); is the documented way of not importing symbols into your namespace. use Module (); does not call import.

      Furthermore, there is no stated requirement for all packages that use a module to use it. I often do use Module (); { package PkgA; ... } { package PkgB; ... } { package PkgC; ... }. Notice import was not called from any of the 4 packages involved.

      A module should not rely on import being called. (Pragmas are another matter.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-19 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found