FreakyGreenLeaky has asked for the wisdom of the Perl Monks concerning the following question:
Greets,
Following on from the great explanation by LanX here Re: Accessing list of package names in a module, I'm now trying to figure out how to dereference a variable who's name has been previously extracted from a module.
Simply put, given the following variable and it's contents (where Util::Stuff:aaa1 comes from a loaded module):
Possible?
Normal usage of Util::Stuff::aaa1 would be
Thanks
Henry
Following on from the great explanation by LanX here Re: Accessing list of package names in a module, I'm now trying to figure out how to dereference a variable who's name has been previously extracted from a module.
Simply put, given the following variable and it's contents (where Util::Stuff:aaa1 comes from a loaded module):
I wish to get at the 'flag' value which is defined in Util::Stuff:aaa1 as:my $var = 'Util::Stuff::aaa1'
Something akin to:package Util::Stuff::aaa1; sub flag { 10 } ...
ie, "interpolate" the variable to get the actual name before dereferencing.print $"$var" # oogly, I know :-)
Possible?
Normal usage of Util::Stuff::aaa1 would be
Apologies if I haven't explained myself clearly.print Util::Stuff::aaa1->flag ...
Thanks
Henry
Back to
Seekers of Perl Wisdom