toddfreed has asked for the wisdom of the Perl Monks concerning the following question:
Hopefully thats pretty self-explanatory. Basically, I want to invoke a package-level method (no objects or blessed references) with inheritance, where I do not know the name of the base class to invoke upon at compile time, but I have it in a scalar at run time. Further, I would like to avoid the use of "eval" if at all possible.package base; sub function { } package derived; our @ISA = qw|base|; package main; derived->function(); # <-- works, not what I want my $pack = "base"; &{"${pack}::functon"}(); # <-- works, not what I want $pack = "derived"; &{"${pack}::function"}(); # <-- doesn't work, this is what I want $pack = "derived"; eval "${pack}->function()"; # <-- works, not what I want
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: symbolic reference + inheritance
by almut (Canon) on Sep 25, 2009 at 20:32 UTC | |
by toddfreed (Novice) on Sep 25, 2009 at 20:57 UTC | |
by merlyn (Sage) on Sep 26, 2009 at 00:44 UTC | |
by almut (Canon) on Sep 25, 2009 at 21:11 UTC | |
by toddfreed (Novice) on Sep 25, 2009 at 21:18 UTC | |
by AnomalousMonk (Archbishop) on Sep 26, 2009 at 09:23 UTC | |
by merlyn (Sage) on Sep 26, 2009 at 16:06 UTC | |
by almut (Canon) on Sep 26, 2009 at 10:03 UTC | |
by AnomalousMonk (Archbishop) on Sep 26, 2009 at 12:30 UTC | |
|