BEGIN { @ISA = qw(Exporter) }
-@EXPORT = qw(Dwarn DwarnS DwarnL DwarnN);
+@EXPORT = qw($Dwarn Dwarn DwarnS DwarnL DwarnN);
sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
+our $Dwarn = \&Dwarn;
+
sub DwarnL { warn Data::Dumper::Concise::Dumper @_; @_ }
sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
warn '$foo => ' . Dumper(@return);
return @return;
+If you want to output a reference returned by a method easily, try $Dwarn
+
+ $foo->bar->{baz}->$Dwarn
+
+is equivalent to:
+
+ my $return = $foo->bar->{baz};
+ warn Dumper($return);
+ return $return;
+
=head1 DESCRIPTION
use Data::Dumper::Concise::Sugar;
-will import Dwarn, DwarnL, DwarnN, and DwarnS into your namespace. Using
+will import Dwarn, $Dwarn, DwarnL, DwarnN, and DwarnS into your namespace. Using
L<Exporter>, so see its docs for ways to make it do something else.
=head2 Dwarn
sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
+=head2 $Dwarn
+
+ $Dwarn = \&Dwarn
+
=head2 DwarnL
sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ }
warn '$foo => ' . Dumper(@return);
return @return;
+If you want to output a reference returned by a method easily, try $Dwarn
+
+ $foo->bar->{baz}->$Dwarn
+
+is equivalent to:
+
+ my $return = $foo->bar->{baz};
+ warn Dumper($return);
+ return $return;
+
=head1 TIPS AND TRICKS
=head2 global usage
can_ok __PACKAGE__, qw{Dwarn DwarnS DwarnL DwarnN};
can_ok 'Devel::Dwarn', qw{Dwarn DwarnS DwarnL DwarnN};
+ok($Dwarn, 'Coderef gets exported too');
is $bar, 'robot', 'Dwarn passes scalars through correctly';
}
+DWARN_CODEREF: {
+ my $foo = ['warn', 'friend']->$Dwarn;
+ is $warned_string,qq{[\n "warn",\n "friend"\n]\n}, 'Dwarn warns lists';
+
+ ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly';
+}
+
DWARNN: {
my $x = [1];
my $foo = DwarnN $x;