good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: Small examples of string evalby stvn (Monsignor) |
on May 13, 2006 at 15:12 UTC ( [id://549240]=note: print w/replies, xml ) | Need Help?? |
He (TheDamian) further advises you to use anonymous subroutines and the CPAN Sub::Installer module when you have a need to create new subroutines that are built around some expression that the user supplies. While Sub::Installer is certainly a good idea (insulating the user from the evils of symbol table manipulation, which is at least as dangerous as string eval in the 'wrong' hands). It's code can hardly be considered to contain "Best Practices" IMO. It clearly abuses UNIVERSAL in a way which affects not only the code which uses it, but all other running Perl code. This is the offending code: This would mean that every Perl object will respond true to the query $object->isa('Sub::Installer'). Again, IMO, that is not a Best Practice, but instead a really really bad idea. Sorry, I am a little passionate about code which tramples over the Perl 5 object model like this. But fear not! CPAN will save the day. As an alternative, I offer Sub::Install an excellent module which does not assert it's will upon your entire runtime.
-stvn
In Section
Seekers of Perl Wisdom
|
|