make "perl -c script/re.pl" not start up the REPL
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / DDC.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::DDC;
4
5 use Devel::REPL::Plugin;
6 use Data::Dumper::Concise ();
7
8 around 'format_result' => sub {
9   my $orig = shift;
10   my $self = shift;
11   my $to_dump = (@_ > 1) ? [@_] : $_[0];
12   my $out;
13   if (ref $to_dump) {
14     if (overload::Method($to_dump, '""')) {
15       $out = "$to_dump";
16     } else {
17       $out = Data::Dumper::Concise::Dumper($to_dump);
18     }
19   } else {
20     $out = $to_dump;
21   }
22   $self->$orig($out);
23 };
24
25 1;
26
27 __END__
28
29 =head1 NAME
30
31 Devel::REPL::Plugin::DDC - Format results with Data::Dumper::Concise
32
33 =head1 SYNOPSIS
34
35  # in your re.pl file:
36  use Devel::REPL;
37  my $repl = Devel::REPL->new;
38  $repl->load_plugin('DDS');
39  $repl->run;
40
41  # after you run re.pl:
42  $ map $_*2, ( 1,2,3 )
43 [
44   2,
45   4,
46   6
47 ];
48
49  $
50
51 =cut
52