perldoc > Eval::TypeTiny

đŸˇī¸ NAME

Eval::TypeTiny - utility to evaluate a string of Perl code in a clean environment

🚀 Quick Reference

Use CaseCommandDescription
Compile a closure from a code stringeval_closure(source => 'sub { ... }', environment => \%env)Compiles a coderef from a Perl code string, with optional closed-over variables
Check alias implementationuse Eval::TypeTiny qw(ALIAS_IMPLEMENTATION);Returns a string indicating which alias implementation is active
Check lexical sub supportuse Eval::TypeTiny qw(HAS_LEXICAL_SUBS);Boolean indicating if lexical subs are supported (requires Perl 5.18+)
Use feature pragma inside evaleval_closure(source => 'sub { use feature qw(say); say for @_ }')Import pragmas inside the evaluated string to enable features

📊 STATUS

This module is covered by the Type-Tiny stability policy.

📖 DESCRIPTION

This module is used by Type::Tiny to compile coderefs from strings of Perl code, and hashrefs of variables to close over.

🧩 Functions

This module exports one function, which works much like the similarly named function from Eval::Closure:

eval_closure(source => $source, environment => \%env, %opt)

đŸ”ĸ Constants

The following constants may be exported, but are not by default.

🔧 EVALUATION ENVIRONMENT

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");

🐛 BUGS

Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.

📚 SEE ALSO

Eval::Closure, Error::TypeTiny::Compilation.

👤 AUTHOR

Toby Inkster <tobyink AT cpan.org>.

ÂŠī¸ COPYRIGHT AND LICENCE

This software is copyright (c) 2013-2014, 2017-2021 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.

âš ī¸ DISCLAIMER OF WARRANTIES

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.

Eval::TypeTiny
đŸˇī¸ NAME 🚀 Quick Reference 📊 STATUS 📖 DESCRIPTION
🧩 Functions đŸ”ĸ Constants
🔧 EVALUATION ENVIRONMENT 🐛 BUGS 📚 SEE ALSO 👤 AUTHOR ÂŠī¸ COPYRIGHT AND LICENCE âš ī¸ DISCLAIMER OF WARRANTIES

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-17 15:48 @216.73.217.35
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^