GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CODE::PERL (3)

.ds Aq ’

NAME

Code::Perl - Produce Perl code from a tree

CONTENTS

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 <fergal@esatclear.ie>.

COPYRIGHT

Copyright 2003 by Fergal Daly <fergal@esatclear.ie>.

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CODE::PERL (3) 2003-06-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.