NAME Code::Perl - Produce Perl code from a tree SYNOPSIS use Code::Perl::Expr qw( :easy ); my $c = derefh(scal('hash'), calls('getkey')); print $c->perl; # ($hash)->{getkey()} DESCRIPTION Code::Perl allows you to build chunks of Perl code as a tree and then when you're finished building, the tree can output the Perl code. This is useful if you have built your own mini-language and you want to generate Perl from it. Rather than generating the Perl at parse time and having to worry about quoting, escaping, parenthese etc, you can just build a tree using Code::Perl and then dump out the correct Perl at the end. INTERFACE All objects in Code::Perl conform to a basic interface. They all have a method "perl()" which when called returns a string of Perl code corresponding to the object. So for example my $s_i = Code::Perl::Expr::Scalar->new(Name => 'i'); print $s_i->perl; # $i my $string = Code::Perl::Expr::String->new(Value => 'hello'); print $string->perl; # "hello" my $list = Code::Perl::Expr::List(Value => [$s_i, $string]); print $list->perl; # $i, "hello" my $sub = Code::Perl::Expr::CallSub(SubName => "fn", Args => $list); print $sub->perl; # fn($i, "hello") Expression types may also implement other methods but they vary from type to type, "perl()" is the only method that is mandatory. STATUS Code::Perl is in development. There are no known bugs however it currently only has support for a limited range of operators, just enough to allow me to compile the TALES expression from Zope's TAL (http://www.zope.com/). Hopefully this will allow Petal (a Perl implementation of TAL) to produce faster code. USAGE See Code::Perl::Expr for details of the available expression types. PROBLEMS Code::Perl currently has no knowledge of operator precedence, so to be safe it uses parentheses even when they are not needed. The code is correct but it will be a little longer and less readable. It should have no impact on the efficience of the code produced. AUTHOR Written by Fergal Daly . COPYRIGHT Copyright 2003 by Fergal Daly . This program is free software and comes with no warranty. It is distributed under the LGPL license See the file LGPL included in this distribution or http://www.fsf.org/licenses/licenses.html.