Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call a method in a dynamically loaded module perl

I am using Module::Load to load a module dynamically. But I am not able to invoke a method defined in the module. Here is what I am doing

my $module = load("Module");
$module->function();

I am getting the following error:

Can't call method "function" without a package or object reference

What is wrong in the above code?

like image 550
Rohit Banga Avatar asked Jul 01 '26 11:07

Rohit Banga


1 Answers

The load function doesn't have a specified return value. I think you're looking for this:

my $module = 'Module';
load($module);
$module->function();
like image 134
mu is too short Avatar answered Jul 03 '26 21:07

mu is too short



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!