Elijah has asked for the wisdom of the Perl Monks concerning the following question:
Here is an example of what I am doing:
And further down in the app, I am calling this eval in a while loop:my %category = ( 'ClassOne' => ['ClassOne', 'process'], 'ClassTwo' => ['ClassTwo', 'process'], 'ClassThree' => ['ClassThree', 'process'], );
Now I want to remove dynamically instantiating the module from the loop and then call the handle->method() from within the loop. What would be the best way to accomplish this?eval 'use Category::'.$category{$$methods{'category'}}[0].';'. 'my $handle = Category::'.$category{$$methods{'category'}}[0].'-> +new();'. '$handle->'.$category{$$methods{'category'}}[1].'($key, $params, +$testCase);'; print $@ if ($@);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamic use/require
by Joost (Canon) on Feb 26, 2008 at 18:38 UTC | |
|
Re: Dynamic use/require
by kyle (Abbot) on Feb 26, 2008 at 18:47 UTC | |
|
Re: Dynamic use/require
by CountZero (Bishop) on Feb 26, 2008 at 20:15 UTC | |
by Joost (Canon) on Feb 27, 2008 at 21:54 UTC | |
by CountZero (Bishop) on Feb 28, 2008 at 20:49 UTC |