in reply to Accessing variables in a runtime-loaded module

The correct syntax for accessing a variable inside another package is $pkgname::varname, but note that this only works if varname is a package variable. If it's lexical (my $varname), then you can't get to it at all from outside the package.

Given that you have the package name inside a variable, things get a little messy. I couldn't find a way to do it without "eval":

print eval("\$${module_name}::description"), "\n";

Replies are listed 'Best First'.
Re^2: Accessing variables in a runtime-loaded module
by srd (Initiate) on Jun 09, 2005 at 13:39 UTC
    Ok, thanks. I'll switch to using package variable then. Less pain all around.