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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Indirect variable name
by moritz (Cardinal) on Nov 20, 2008 at 12:57 UTC | |
by FreakyGreenLeaky (Sexton) on Nov 20, 2008 at 13:01 UTC | |
| |
by FreakyGreenLeaky (Sexton) on Nov 20, 2008 at 13:23 UTC | |
by moritz (Cardinal) on Nov 20, 2008 at 13:30 UTC | |
by LanX (Saint) on Nov 21, 2008 at 00:08 UTC | |
by moritz (Cardinal) on Nov 21, 2008 at 07:18 UTC | |
| |
by blazar (Canon) on Nov 20, 2008 at 20:59 UTC | |
by LanX (Saint) on Nov 20, 2008 at 23:51 UTC | |
| |
by FreakyGreenLeaky (Sexton) on Nov 20, 2008 at 16:29 UTC | |
by JadeNB (Chaplain) on Nov 20, 2008 at 17:08 UTC | |
| |
by FreakyGreenLeaky (Sexton) on Nov 20, 2008 at 13:40 UTC | |
by Anonymous Monk on Nov 20, 2008 at 16:03 UTC | |
by LanX (Saint) on Nov 20, 2008 at 14:08 UTC | |
Re: Indirect variable name
by GrandFather (Saint) on Nov 20, 2008 at 20:45 UTC |
Back to
Seekers of Perl Wisdom