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.)