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