Eval::Compile - Perl extension for compile eval
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 }
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
None by default.
PadWalker, perlapi, perlfunc
A. G. Grishayev, <grian@cpan.org<gt>
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.
1 POD Error
The following errors were encountered while parsing the POD:
Unknown directive: =THREAD
To install Eval::Compile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Eval::Compile
CPAN shell
perl -MCPAN -e shell install Eval::Compile
For more information on module installation, please visit the detailed CPAN module installation guide.