Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Accessing variables in a runtime-loaded module

by splinky (Hermit)
on Jun 09, 2005 at 13:31 UTC ( [id://465118]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-26 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found