Anupama G
Anupama G

Reputation: 311

Perl Module::Load - using the "load" function to import all the default functions

I'm using Module::Load to load certain modules at runtime. However, I have to make do with an older version (2013) that does not import the autoload function.

Thus, I'm doing something like this:

use Module::Load;

if(some condition)
{
  load "Cwd", qw(getcwd abs_path);
}

I can now use the getcwd() and abs_path() functions provided by the Cwd module.

This is clearly not practical when I need to load a module that imports a lot of functions. How can I use load and still manage to import all the default functions without having to quote them all?

Upvotes: 1

Views: 191

Answers (1)

ysth
ysth

Reputation: 98423

It is usually a better idea to just import what you are actually using. That said, many modules can be asked for qw(:DEFAULT) to explicitly get all the default exports.

Upvotes: 2

Related Questions