Commit | Line | Data |
950232b2 |
1 | package Devel::REPL::Plugin::DDS; |
2 | |
6a5409bc |
3 | use Devel::REPL::Plugin; |
950232b2 |
4 | use Data::Dump::Streamer (); |
5 | |
e22aa835 |
6 | around 'format_result' => sub { |
767c76dd |
7 | my $orig = shift; |
8 | my $self = shift; |
9 | my @to_dump = @_; |
10 | my $out; |
11 | if (@to_dump != 1 || ref $to_dump[0]) { |
12 | if (@to_dump == 1 && overload::Method($to_dump[0], '""')) { |
13 | $out = "@to_dump"; |
14 | } else { |
15 | my $dds = Data::Dump::Streamer->new; |
16 | $dds->Freezer(sub { "$_[0]"; }); |
17 | $dds->Data(@to_dump); |
18 | $out = $dds->Out; |
19 | } |
20 | } else { |
21 | $out = $to_dump[0]; |
22 | } |
23 | $self->$orig($out); |
950232b2 |
24 | }; |
25 | |
26 | 1; |
cfd1094b |
27 | |
28 | __END__ |
29 | |
30 | =head1 NAME |
31 | |
32 | Devel::REPL::Plugin::DDS - Format results with Data::Dump::Streamer |
33 | |
e4761e81 |
34 | =head1 SYNOPSIS |
35 | |
36 | # in your re.pl file: |
37 | use Devel::REPL; |
38 | my $repl = Devel::REPL->new; |
39 | $repl->load_plugin('DDS'); |
40 | $repl->run; |
41 | |
42 | # after you run re.pl: |
43 | $ map $_*2, ( 1,2,3 ) |
44 | $ARRAY1 = [ |
45 | 2, |
46 | 4, |
47 | 6 |
48 | ]; |
49 | |
50 | $ |
51 | |
cfd1094b |
52 | =cut |
53 | |