in reply to loading modules at runtime

The standard way is:

require Module; import Module PARAMETERS;

See use, require.

--
David Serrano

Replies are listed 'Best First'.
Re^2: loading modules at runtime
by chromatic (Archbishop) on Oct 14, 2006 at 20:31 UTC
    Module->import( PARAMETERS );

    Indirect method invocation has severe and difficult-to-debug ambiguities.

      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.

        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();

        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.