I have a module which looks like this:
package Test;
use strict;
use warnings;
sub hello {
my $val = shift
print "val = $val\n";
}
and in another module I insert this one like this:
my $module = 'Test'
eval "require $module";
How can I call the function hello in the second module /I mean like a function not like a method/.
You can use a symbolic reference:
Alternatively, you can export the function to the calling package (see Exporter):
Then in your code: