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