Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^3: Loading a Module from a Variableby nobull (Friar) |
on Sep 21, 2005 at 16:46 UTC ( [id://493867]=note: print w/replies, xml ) | Need Help?? |
eval, unlike require does not evaluate the code in a new top-level lexical scope. Any lexically scoped varaibles or pragmas will be inherited by the code.
One way to avoid use strict and use warnings being inherited by your evaled source is to simply no strict; no warnings; before you eval. To avoid lexical variables, put the eval() in a subroutine that appears before any file scoped lexicals (and before the pragmas too).
A completely different approach would be to put a code reference into @INC. That way you can actually use require.
In Section
Seekers of Perl Wisdom
|
|