From: Arthur Axel 'fREW' Schmidt Date: Wed, 1 Jan 2014 00:56:59 +0000 (-0600) Subject: Make Dwarn output all arguments even in scalar context X-Git-Tag: v2.021~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d51197846c3fe198ef94aa255efbbad77432d02;p=p5sagit%2FData-Dumper-Concise.git Make Dwarn output all arguments even in scalar context --- diff --git a/Changes b/Changes index c528614..25dc3a0 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +2.021 Dec 31 2013 + - Make Dwarn output all arguments even in scalar context + (retun val is still the same though) + 2.020 Jan 20 2011 - Add DumperObject for getting at the underlying obj - create DwarnF for formatting Dumper'd output diff --git a/lib/Data/Dumper/Concise/Sugar.pm b/lib/Data/Dumper/Concise/Sugar.pm index b37cff4..fa65682 100644 --- a/lib/Data/Dumper/Concise/Sugar.pm +++ b/lib/Data/Dumper/Concise/Sugar.pm @@ -12,7 +12,7 @@ BEGIN { @ISA = qw(Exporter) } $Ddie $DdieN Ddie DdieS DdieL DdieN DdieD ); -sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } +sub Dwarn { DwarnL(@_); return wantarray ? @_ : $_[0] } our $Dwarn = \&Dwarn; our $DwarnN = \&DwarnN; @@ -29,7 +29,7 @@ sub DwarnN ($) { sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } -sub Ddie { DdieL(@_) if wantarray; DdieS($_[0]) } +sub Ddie { DdieL(@_); return wantarray ? @_ : $_[0] } our $Ddie = \&Ddie; our $DdieN = \&DdieN; diff --git a/t/sugar.t b/t/sugar.t index 20eb013..2ccc009 100644 --- a/t/sugar.t +++ b/t/sugar.t @@ -34,7 +34,7 @@ DWARN: { ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes lists through correctly'; my $bar = Dwarn 'robot',2,3; - is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly'; + is $warned_string,qq{"robot"\n2\n3\n}, 'Dwarn warns scalars correctly'; is $bar, 'robot', 'Dwarn passes scalars through correctly'; }