Commit | Line | Data |
1716b200 |
1 | use strict; |
2 | use warnings; |
381b5fa4 |
3 | package Devel::REPL::Plugin::DDC; |
9d2a4940 |
4 | # ABSTRACT: Format results with Data::Dumper::Concise |
381b5fa4 |
5 | |
5ac98890 |
6 | our $VERSION = '1.003028'; |
54beb05d |
7 | |
381b5fa4 |
8 | use Devel::REPL::Plugin; |
9 | use Data::Dumper::Concise (); |
1d6c2dbc |
10 | use namespace::autoclean; |
381b5fa4 |
11 | |
12 | around 'format_result' => sub { |
13 | my $orig = shift; |
14 | my $self = shift; |
15 | my $to_dump = (@_ > 1) ? [@_] : $_[0]; |
16 | my $out; |
17 | if (ref $to_dump) { |
18 | if (overload::Method($to_dump, '""')) { |
19 | $out = "$to_dump"; |
20 | } else { |
21 | $out = Data::Dumper::Concise::Dumper($to_dump); |
22 | } |
23 | } else { |
24 | $out = $to_dump; |
25 | } |
26 | $self->$orig($out); |
27 | }; |
28 | |
29 | 1; |
30 | |
31 | __END__ |
32 | |
9d2a4940 |
33 | =pod |
381b5fa4 |
34 | |
35 | =head1 SYNOPSIS |
36 | |
37 | # in your re.pl file: |
38 | use Devel::REPL; |
39 | my $repl = Devel::REPL->new; |
40 | $repl->load_plugin('DDS'); |
41 | $repl->run; |
42 | |
43 | # after you run re.pl: |
44 | $ map $_*2, ( 1,2,3 ) |
45 | [ |
46 | 2, |
47 | 4, |
48 | 6 |
49 | ]; |
50 | |
51 | $ |
52 | |
53 | =cut |