The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::EvalServerAdvanced::Sandbox::Internal

SYNOPSIS

This is an internal class used as part of the plugin system for the sandbox. This is where all the plugin roles for the sandbox end up.

CUSTOM LANGUAGE PROCESSING When configuring the server and setting up a language, you can create a function that looks like the following:

    sub run_perl {
        my( $class, $lang, $code ) = @_;
        ...
    }

The first argument $class is pretty much useless. It will always be App::EvalServerAdvanced::Sandbox::Internal, as your subroutine is called as a dynamic method call.

In the configuration you can setup the language thusly,

    [language.perl]
    sub="deparse_perl"
    seccomp_profile="lang_perl"

That subroutine, deparse_perl, will then be called and told the name of the language, and the code so you can do whatever processing is needed.

TEMPLATING CODE

You can also use this to template the code being passed to an external interpreter.

    sub perl_wrap {
        my ($class, $lang, $code) = @_;
        my $qcode = quotemeta $code;

        my $wrapper = 'use Data::Dumper;

        local $Data::Dumper::Terse = 1;
        local $Data::Dumper::Quotekeys = 0;
        local $Data::Dumper::Indent = 0;
        local $Data::Dumper::Useqq = 1;

        my $val = eval "#line 1 \"(IRC)\"\n'.$qcode.'";

        if ($@) {
          print $@;
        } else {
          $val = ref($val) ? Dumper ($val) : "".$val;
          print " ",$val;
        }
        ';
        return $wrapper;
    }

And in the configuration of the EvalServer

    [language."perl5.8"]
    bin="/perl5/perlbrew/perls-5.8.9/bin/perl"
    args=["-e", "%CODE%"]
    wrap_code="perl_wrap"
    seccomp_profile="lang_perl"

This lets you manipulate the code before it's passed to the interpreter and make any changes necessary.

AUTHOR

Ryan Voots <simcop@cpan.org>