Keep It Simple, Stupid | |
PerlMonks |
Re: Code Generation with Perl?by demerphq (Chancellor) |
on Oct 04, 2003 at 10:56 UTC ( [id://296490]=note: print w/replies, xml ) | Need Help?? |
As others have pointed out Perl has a long heritage of code generation. Documentation that has been bundled with Perl for a long time explains some common usages. perltoot and perltootc. Data::Dumper, also bundled with Perl for ages is a classic code generator. Turning an in memory data structure into a program that should recreate the same data structure when evaled. Since perl has a such powerful string manipulation abilities, and the handy eval and closure, dynamic run time code generation is a common and powerful technique for reducing coding overhead and error. Personally I've done a variety of funky code generation. Have a look at Algorithm::Treap for an example of using import() and code manipulation to turn a package into a class factory. This area is well worth experimentation and once you are comfortable with it, use in production enviornments is perfectly acceptable.
---
demerphq First they ignore you, then they laugh at you, then they fight you, then you win.
In Section
Seekers of Perl Wisdom
|
|