use Term::ReadLine;
use Moose;
-use namespace::clean;
+use namespace::clean -except => [ 'meta' ];
with 'MooseX::Object::Pluggable';
}
sub compile {
- my ($self, $line) = @_;
- my $compiled = eval $self->wrap_as_sub($line);
- return (undef, $self->error_return("Compile error", $@)) if $@;
+ my $REPL = shift;
+ my $compiled = eval $REPL->wrap_as_sub($_[0]);
+ return (undef, $REPL->error_return("Compile error", $@)) if $@;
return $compiled;
}
}
sub execute {
- my $REPL = shift;
- my @ret = eval { shift->(@_) };
- return $REPL->error_return("Runtime error", $@) if $@;
+ my ($self, $to_exec, @args) = @_;
+ my @ret = eval { $to_exec->(@args) };
+ return $self->error_return("Runtime error", $@) if $@;
return @ret;
}