1 package Data::Dumper::Concise::Sugar;
6 use Data::Dumper::Concise ();
8 BEGIN { @ISA = qw(Exporter) }
10 @EXPORT = qw(Dwarn DwarnS DwarnL);
12 sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
14 sub DwarnL { warn Data::Dumper::Concise::Dumper @_; @_ }
16 sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
20 Data::Dumper::Concise::Sugar - return Dwarn @return_value
24 use Data::Dumper::Concise::Sugar;
26 return Dwarn some_call(...)
30 use Data::Dumper::Concise;
33 my @return = some_call(...);
37 my $return = some_call(...);
42 but shorter. If you need to force scalar context on the value,
44 use Data::Dumper::Concise::Sugar;
46 return DwarnS some_call(...)
50 use Data::Dumper::Concise;
52 my $return = some_call(...);
56 If you need to force list context on the value,
58 use Data::Dumper::Concise::Sugar;
60 return DwarnL some_call(...)
64 use Data::Dumper::Concise;
66 my @return = some_call(...);
72 use Data::Dumper::Concise::Sugar;
74 will import Dwarn, DwarnL, and DwarnS into your namespace. Using L<Exporter>, so see
75 its docs for ways to make it do something else.
79 sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
83 sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ }
87 sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
89 =head1 TIPS AND TRICKS
93 Instead of always just doing:
95 use Data::Dumper::Concise::Sugar;
101 perl -MData::Dumper::Concise::Sugar foo.pl
103 (and then in the perl code:)
107 That way, if you leave them in and run without the
108 C<< use Data::Dumper::Concise::Sugar >> the program will fail to compile and
109 you are less likely to check it in by accident. Furthmore it allows that
110 much less friction to add debug messages.
112 =head2 method chaining
114 One trick which is useful when doing method chaining is the following:
117 $foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff;
119 which is the same as:
122 (DwarnS $foo->bar->baz)->biff;
126 You probably want L<Devel::Dwarn>, it's the shorter name for this module.