1 package Devel::REPL::Plugin::DumpHistory;
3 use Devel::REPL::Plugin;
4 use namespace::autoclean;
6 ## Seems to be a sequence issue with requires
7 # requires qw{ history };
11 my ($self, @args) = @_;
13 my $line = $self->$orig(@args);
15 if ($line =~ m/^:dump ?(.*)$/) {
17 $self->print_history($file);
25 my ( $self, $file ) = @_;
28 open( my $fd, ">>", $file )
29 or do { warn "Couldn't open '$file': $!\n"; return; };
30 print $fd "$_\n" for ( @{ $self->history } );
31 $self->print( sprintf "Dumped %d history lines to '$file'\n",
32 scalar @{ $self->history } );
35 $self->print("$_\n") for ( @{ $self->history } );
46 Devel::REPL::Plugin::DumpHistory - Plugin for Devel::REPL to save or print
56 my $repl = Devel::REPL->new;
57 $repl->load_plugin('LexEnv');
58 $repl->load_plugin('History');
59 $repl->load_plugin('DumpHistory');
64 Plugin that adds the C<:dump> and C<:dump file_name> commands to the
65 repl which will print the history to STDOUT or append the history to the
74 mgrimes, E<lt>mgrimes at cpan dot org<gt>
76 =head1 COPYRIGHT AND LICENSE
78 Copyright (C) 2007 by mgrimes
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself, either Perl version 5.8.2 or,
82 at your option, any later version of Perl 5 you may have available.