Анатолий Гришаев > Eval-Compile-0.11 > Eval::Compile

Download:
Eval-Compile-0.11.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.11   Source  

NAME ^

Eval::Compile - Perl extension for compile eval

SYNOPSIS ^

  use Eval::Compile qw(ceval cache_this cache_eval_undef);
  my $eval_string = '1+$a';

  for my $a  ( 1, 2, 3){
          my $result = ceval( $eval_string ); # like eval only faster 
          print $eval_string, " = ", $result, "\n";
  }
  # prints
#  1+$a = 2
#  1+$a = 3
#  1+$a = 4
        
  cache_eval_undef( ) ; # flush out current compiled eval cache

  # Simple results caching
  for my $b  ( 1,1,3,4){
          my $r = cache_this( $b, sub { my $c = shift; heavy ops here ; return $heavy } ); # called only once for each $b
  }

  sub print_if_i_have_seen_this{
          my $this = shift;
          cache_this( $this, sub { print $this, "\n" }); #Stupid but efficient
  }

DESCRIPTION ^

Faster replacement for string evals. It takes evaled strings and compiles into specific perl sub with some data, and do it once for any given string So next execution take a fraction of first eval to execute.

Not yet ready. This module is not threads safe

EXPORT

None by default.

SEE ALSO ^

PadWalker, perlapi, perlfunc

AUTHOR ^

A. G. Grishayev, <grian@cpan.org<gt>

COPYRIGHT AND LICENSE ^

Copyright (C) 2010 by A. G. Grishayev

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: