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