Re: retrieving a constant from a dynamically loaded module



olivier.grant@xxxxxxxxx wrote:
I need to be able to dynamically load a module and retrieve a constant
from it. Simply put, i want to allow a user to specify a module
HisModule.pm containing the package HisModule and get
HisModule::VERSION.

in his file :
[code]
package HisModule;
use constant VERSION;
1;
[/code]

in my code :
[code]
$module = shift @ARGV;

chomp $module; require $module;

print " Using module v".$module::VERSION."\n";
[/code]

-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl .