NAME

eval - Eval code

VERSION

This document describes version 0.001 of eval (from Perl distribution eval), released on 2019-10-19.

SYNOPSIS

Use in one-liner or in PERL5OPT:

 % perl -Meval='$Carp::MaxArgLen = 1000' script.pl

 % DEBUG=1 PERL5OPT='-Meval=$Carp::MaxArgLen=1000' script.pl
 eval.pm: Eval'ing: $Carp::MaxArgLen=1000

DESCRIPTION

This pragma lets you run some Perl code before running your script. Some other ways to accomplish the same include:

  • creating $Config{sitelib}/sitecustomize.pl

    See perlrun.

  • putting your code in a module and load it using -m or -M

    For example, you put your code in lib/Foo.pm and run your script using:

     % PERL5OPT="-Ilib -MFoo" script.pl
  • do

     % perl -e'$Carp::MaxArgLen = 1000; do "script.pl"'

Some caveats:

  • No whitespace in code in PERL5OPT

    Space is used to separate perl options in PERL5OPT, so you can't do:

     % PERL5OPT='-Meval=$Carp::MaxArgLen = 1000' script.pl

    but you can do:

     % PERL5OPT='-Meval=$Carp::MaxArgLen=1000' script.pl

    To help you see what code is being eval'ed, set DEBUG to true:

     % PERL5OPT='-Meval=$Carp::MaxArgLen=1000' script.pl
     eval.pm: Eval'ing: $Carp::MaxArgLen=1000

ENVIRONMENT

DEBUG

Bool. If set to true, will show what code is being eval'ed.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/eval.

SOURCE

Source repository is at https://github.com/perlancar/perl-eval.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=eval

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.