5 use namespace::clean -except => [ 'meta' ];
6 use 5.8.1; # might work with earlier perls but probably not
8 our $VERSION = '1.002001'; # 1.2.1
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);
44 eval { $self->print("Error printing! - $error\n"); };
51 return $self->term->readline($self->prompt);
55 my ($self, $line) = @_;
56 my ($to_exec, @rest) = $self->compile($line);
57 return @rest unless defined($to_exec);
58 my @ret = $self->execute($to_exec);
64 my $compiled = eval $_REPL->wrap_as_sub($_[0]);
65 return (undef, $_REPL->error_return("Compile error", $@)) if $@;
70 my ($self, $line) = @_;
71 return qq!sub {\n!.$self->mangle_line($line).qq!\n}\n!;
75 my ($self, $line) = @_;
80 my ($self, $to_exec, @args) = @_;
81 my @ret = eval { $to_exec->(@args) };
82 return $self->error_return("Runtime error", $@) if $@;
87 my ($self, $type, $error) = @_;
88 return "${type}: ${error}";
92 my ($self, @ret) = @_;
93 my $fh = $self->out_fh;
94 no warnings 'uninitialized';
96 print $fh "\n" if $self->term->ReadLine =~ /Gnu/;
101 Devel::REPL - a modern perl interactive shell
105 my $repl = Devel::REPL->new;
106 $repl->load_plugin($_) for qw(History LexEnv);
109 Alternatively, use the 're.pl' script installed with the distribution
115 Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>)
121 =item Stevan Little - stevan (at) iinteractive.com
123 =item Alexis Sukrieh - sukria+perl (at) sukria.net
127 =item mgrimes - mgrimes (at) cpan dot org
129 =item Shawn M Moore - sartak (at) gmail.com
135 This library is free software under the same terms as perl itself