Perl-Sensitive Sunglasses | |
PerlMonks |
Hygienic eval of templates with perl code?by LanX (Saint) |
on Aug 27, 2014 at 03:28 UTC ( [id://1098694]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi I have the feeling of reinventing the wheel and would like to see other solutions... I'm evaling code text which is composed of 2 snippets which are supposed to be correct in isolation. Take as example using B::Deparse to back engineer a functions code and then wrapping new code around it before evaling. (something like this is shown in the Perl Hacks book) Now this additional code could contain new symbols (identifiers) like variables, subnames or labels which might shadow equally named symbols in the original code. This is known as Hygiene Problem. I decided to solve this with a template system where new symbols need to be placeholders, which are renamed (extended with a suffix) if they conflict with old symbols. Did anybody already try to solve this on CPAN? I'd like to compare different approaches.
Cheers Rolf (addicted to the Perl Programming Language and ☆☆☆☆ :)
Back to
Seekers of Perl Wisdom
|
|