Don't ask to ask, just ask | |
PerlMonks |
Re^5: eval "require $class" seems wrongby ikegami (Patriarch) |
on Aug 22, 2007 at 20:12 UTC ( [id://634510]=note: print w/replies, xml ) | Need Help?? |
No, you don't need either eval functions to conditionally load a module.
And you don't need eval EXPR* to do exception handling.
You only need eval EXPR to load a module whose name is not known at compile-time. The only things I can think of that fits that description are plugins/drivers, things well served by high-level modules. Do you have an example that requires require $class other than plugins/drivers? * — Remember, nothing wrong with eval BLOCK (called try in some other languages). Unlike eval EXPR, it doesn't invoke the Perl compiler. That means it doesn't incure a huge speed penalty and it doesn't require careful escaping and validation its argument.
In Section
Seekers of Perl Wisdom
|
|