X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FDDS.pm;h=6e01fe7145469f1289f3cad2ddaa14bbb950ea4b;hp=50464e008467197ba4ce6296d54c223cd0ae6263;hb=e4761e81ea1521f1daf146e8e5ec066b40d35888;hpb=cfd1094b45c394258ccda08216f1435bf40e1d50 diff --git a/lib/Devel/REPL/Plugin/DDS.pm b/lib/Devel/REPL/Plugin/DDS.pm index 50464e0..6e01fe7 100644 --- a/lib/Devel/REPL/Plugin/DDS.pm +++ b/lib/Devel/REPL/Plugin/DDS.pm @@ -1,6 +1,6 @@ package Devel::REPL::Plugin::DDS; -use Moose::Role; +use Devel::REPL::Plugin; use Data::Dump::Streamer (); around 'format_result' => sub { @@ -9,10 +9,14 @@ around 'format_result' => sub { my $to_dump = (@_ > 1) ? [@_] : $_[0]; my $out; if (ref $to_dump) { - my $dds = Data::Dump::Streamer->new; - $dds->Freezer(sub { "$_[0]"; }); - $dds->Data($to_dump); - $out = $dds->Out; + if (overload::Method($to_dump, '""')) { + $out = "$to_dump"; + } else { + my $dds = Data::Dump::Streamer->new; + $dds->Freezer(sub { "$_[0]"; }); + $dds->Data($to_dump); + $out = $dds->Out; + } } else { $out = $to_dump; } @@ -27,5 +31,23 @@ __END__ Devel::REPL::Plugin::DDS - Format results with Data::Dump::Streamer +=head1 SYNOPSIS + + # in your re.pl file: + use Devel::REPL; + my $repl = Devel::REPL->new; + $repl->load_plugin('DDS'); + $repl->run; + + # after you run re.pl: + $ map $_*2, ( 1,2,3 ) + $ARRAY1 = [ + 2, + 4, + 6 + ]; + + $ + =cut