Commit | Line | Data |
1716b200 |
1 | use strict; |
2 | use warnings; |
381b5fa4 |
3 | package Devel::REPL::Plugin::DDC; |
4 | |
54beb05d |
5 | our $VERSION = '1.003027'; |
6 | |
381b5fa4 |
7 | use Devel::REPL::Plugin; |
8 | use Data::Dumper::Concise (); |
1d6c2dbc |
9 | use namespace::autoclean; |
381b5fa4 |
10 | |
11 | around 'format_result' => sub { |
12 | my $orig = shift; |
13 | my $self = shift; |
14 | my $to_dump = (@_ > 1) ? [@_] : $_[0]; |
15 | my $out; |
16 | if (ref $to_dump) { |
17 | if (overload::Method($to_dump, '""')) { |
18 | $out = "$to_dump"; |
19 | } else { |
20 | $out = Data::Dumper::Concise::Dumper($to_dump); |
21 | } |
22 | } else { |
23 | $out = $to_dump; |
24 | } |
25 | $self->$orig($out); |
26 | }; |
27 | |
28 | 1; |
29 | |
30 | __END__ |
31 | |
32 | =head1 NAME |
33 | |
34 | Devel::REPL::Plugin::DDC - Format results with Data::Dumper::Concise |
35 | |
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 | [ |
47 | 2, |
48 | 4, |
49 | 6 |
50 | ]; |
51 | |
52 | $ |
53 | |
54 | =cut |
55 | |