So, in your first code segment, the 'use $plugin' is evaluated before $plugin contains any data, and is doomed to fail.
Your second code segment merely places some text (which happens to be 'use something_or_other') into a variable, then evaluates the variable in a void context (which in this case means that the value of the variable is returned and disappears, unused, immediately).
Try replacing the 'use' in the first segment with
- then as long as $plugin contains something that looks like a module name, you should load and evaluate the code in that module at run-time. The eval is required as you have generated the code to be executed on the fly, and perl has not yet had a chance to generate the necessary opcodes that it must run; when you give the string containing "require $plugin" to eval, it assumes the string contains Perl code, and compiles and runs it.eval "require $plugin";
You say that you've tried 'eval' and 'require' but without seeing the code, it's hard to say what went wrong before.
Steve Collyer
In reply to Re: Loading all files in a dir with use via for loop
by scollyer
in thread Loading all files in a dir with use via for loop
by Delusional
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |