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