line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
2296
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
62
|
|
2
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
106
|
|
3
|
|
|
|
|
|
|
package Devel::REPL::Plugin::DumpHistory; |
4
|
|
|
|
|
|
|
# ABSTRACT: Plugin for Devel::REPL to save or print the history |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.003028'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use Devel::REPL::Plugin; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
9
|
2
|
|
|
2
|
|
6114
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
## Seems to be a sequence issue with requires |
12
|
|
|
|
|
|
|
# requires qw{ history }; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
around 'read' => sub { |
15
|
|
|
|
|
|
|
my $orig = shift; |
16
|
|
|
|
|
|
|
my ($self, @args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $line = $self->$orig(@args); |
19
|
|
|
|
|
|
|
if (defined $line) { |
20
|
|
|
|
|
|
|
if ($line =~ m/^:dump ?(.*)$/) { |
21
|
|
|
|
|
|
|
my $file = $1; |
22
|
|
|
|
|
|
|
$self->print_history($file); |
23
|
|
|
|
|
|
|
return ''; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
return $line; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub print_history { |
30
|
0
|
|
|
0
|
0
|
|
my ( $self, $file ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($file) { |
33
|
|
|
|
|
|
|
open( my $fd, ">>", $file ) |
34
|
0
|
0
|
|
|
|
|
or do { warn "Couldn't open '$file': $!\n"; return; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
print $fd "$_\n" for ( @{ $self->history } ); |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->print( sprintf "Dumped %d history lines to '$file'\n", |
37
|
0
|
|
|
|
|
|
scalar @{ $self->history } ); |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
close $fd; |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
|
$self->print("$_\n") for ( @{ $self->history } ); |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
return 1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding UTF-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Devel::REPL::Plugin::DumpHistory - Plugin for Devel::REPL to save or print the history |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
version 1.003028 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Devel::REPL; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $repl = Devel::REPL->new; |
66
|
|
|
|
|
|
|
$repl->load_plugin('LexEnv'); |
67
|
|
|
|
|
|
|
$repl->load_plugin('History'); |
68
|
|
|
|
|
|
|
$repl->load_plugin('DumpHistory'); |
69
|
|
|
|
|
|
|
$repl->run; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Plugin that adds the C<:dump> and C<:dump file_name> commands to the |
74
|
|
|
|
|
|
|
repl which will print the history to STDOUT or append the history to the |
75
|
|
|
|
|
|
|
file given. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
C<Devel::REPL> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SUPPORT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> |
84
|
|
|
|
|
|
|
(or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>). |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
87
|
|
|
|
|
|
|
L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
mgrimes, E<lt>mgrimes at cpan dot org<gt> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Copyright (C) 2007 by mgrimes |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
98
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
99
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |