doc for chaining feature
[p5sagit/Data-Dumper-Concise.git] / lib / Data / Dumper / Concise / Sugar.pm
CommitLineData
ce1f3e8e 1package Data::Dumper::Concise::Sugar;
2
3use 5.006;
4
5use Exporter ();
6use Data::Dumper::Concise ();
7
8BEGIN { @ISA = qw(Exporter) }
9
10@EXPORT = qw(Dwarn DwarnS);
11
12sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ }
13
14sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
15
16=head1 NAME
17
18Data::Dumper::Concise::Sugar - return Dwarn @return_value
19
20=head1 SYNOPSIS
21
22 use Data::Dumper::Concise::Sugar;
23
24 return Dwarn some_call(...)
25
26is equivalent to:
27
28 use Data::Dumper::Concise;
29
30 my @return = some_call(...);
31 warn Dumper(@return);
32 return @return;
33
34but shorter. If you need to force scalar context on the value,
35
36 use Data::Dumper::Concise::Sugar;
37
38 return DwarnS some_call(...)
39
40is equivalent to:
41
42 use Data::Dumper::Concise;
43
44 my $return = some_call(...);
45 warn Dumper($return);
46 return $return;
47
01223632 48Another trick that is extremely useful when doing method chaining is the
49following:
50
51 my $foo = Bar->new;
52 $foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff;
53
54which is the same as:
55
56 my $foo = Bar->new;
57 (DwarnS $foo->bar->baz)->biff;
58
ce1f3e8e 59=head1 DESCRIPTION
60
61 use Data::Dumper::Concise::Sugar;
62
63will import Dwarn and DwarnS into your namespace. Using L<Exporter>, so see
64its docs for ways to make it do something else.
65
66=head2 Dwarn
67
68 sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ }
69
70=head3 DwarnS
71
72 sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
73
dc06d25b 74=head1 SEE ALSO
75
76You probably want L<Devel::Dwarn>, it's the shorter name for this module.
77
78=cut
ce1f3e8e 79
801;