Eval::TypeTiny - utility to evaluate a string of Perl code in a clean environment
This is not considered part of Type::Tiny's public API.
This module exports one function, which works much like the similarly named function from Eval::Closure:
eval_closure(source => $source, environment => \%env, %opt)
The following constants may be exported, but are not by default.
HAS_LEXICAL_SUBS
Boolean indicating whether Eval::TypeTiny has support for lexical subs. (This feature requires Perl 5.18.)
HAS_LEXICAL_VARS
Don't worry; closing over lexical variables in the closures is always supported! However, if this constant is true, it means that Devel::LexAlias is available, which makes them slightly faster than the fallback solution which uses tied variables. (This only makes any difference when the alias => 1 option is used.)
alias => 1
The evaluation is performed in the presence of strict, but the absence of warnings. (This is different to Eval::Closure which enables warnings for compiled closures.)
The feature pragma is not active in the evaluation environment, so the following will not work:
use feature qw(say); use Eval::TypeTiny qw(eval_closure); my $say_all = eval_closure( source => 'sub { say for @_ }', ); $say_all->("Hello", "World");
The feature pragma does not "carry over" into the stringy eval. It is of course possible to import pragmas into the evaluated string as part of the string itself:
use Eval::TypeTiny qw(eval_closure); my $say_all = eval_closure( source => 'sub { use feature qw(say); say for @_ }', ); $say_all->("Hello", "World");
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny.
Eval::Closure, Error::TypeTiny::Compilation.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Type::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::Tiny
CPAN shell
perl -MCPAN -e shell install Type::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.