5 use namespace::clean -except => [ 'meta' ];
6 use 5.8.1; # might work with earlier perls but probably not
8 our $VERSION = '1.001000'; # 1.1.0
10 with 'MooseX::Object::Pluggable';
13 is => 'rw', required => 1,
14 default => sub { Term::ReadLine->new('Perl REPL') }
18 is => 'rw', required => 1,
19 default => sub { '$ ' }
23 is => 'rw', required => 1, lazy => 1,
24 default => sub { shift->term->OUT || \*STDOUT; }
29 while ($self->run_once) {
36 my $line = $self->read;
37 return unless defined($line); # undefined value == EOF
38 my @ret = $self->eval($line);
45 return $self->term->readline($self->prompt);
49 my ($self, $line) = @_;
50 my ($to_exec, @rest) = $self->compile($line);
51 return @rest unless defined($to_exec);
52 my @ret = $self->execute($to_exec);
58 my $compiled = eval $_REPL->wrap_as_sub($_[0]);
59 return (undef, $_REPL->error_return("Compile error", $@)) if $@;
64 my ($self, $line) = @_;
65 return qq!sub {\n!.$self->mangle_line($line).qq!\n}\n!;
69 my ($self, $line) = @_;
74 my ($self, $to_exec, @args) = @_;
75 my @ret = eval { $to_exec->(@args) };
76 return $self->error_return("Runtime error", $@) if $@;
81 my ($self, $type, $error) = @_;
82 return "${type}: ${error}";
86 my ($self, @ret) = @_;
87 my $fh = $self->out_fh;
88 no warnings 'uninitialized';
94 Devel::REPL - a modern perl interactive shell
98 my $repl = Devel::REPL->new;
99 $repl->load_plugin($_) for qw(History LexEnv);
102 Alternatively, use the 're.pl' script installed with the distribution
108 Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>)
112 This library is free software under the same terms as perl itself