1 package Devel::REPL::Plugin::History;
6 isa => 'ArrayRef', is => 'rw', required => 1, lazy => 1,
11 my ($self, $line) = @_;
12 push(@{$self->history}, $line);
15 around 'read' => sub {
17 my ($self, @args) = @_;
18 my $line = $self->$orig(@args);
20 if ($line =~ m/^!(.*)$/) {
22 $line = $self->history_call($call);
24 $self->print($line."\n");
26 return "'Unable to find ${call} in history'";
30 $self->push_history($line);
37 my ($self, $call) = @_;
38 if ($call =~ m/^(-?\d+)$/) { # handle !1 or !-1
40 $idx-- if ($idx > 0); # !1 gets history element 0
41 my $line = $self->history->[$idx];
44 my $re = qr/^\Q${call}\E/;
45 foreach my $line (reverse @{$self->history}) {
46 return $line if ($line =~ $re);