Commit | Line | Data |
ce1f3e8e |
1 | package Data::Dumper::Concise::Sugar; |
2 | |
3 | use 5.006; |
4 | |
5 | use Exporter (); |
6 | use Data::Dumper::Concise (); |
7 | |
8 | BEGIN { @ISA = qw(Exporter) } |
9 | |
10 | @EXPORT = qw(Dwarn DwarnS); |
11 | |
12 | sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ } |
13 | |
14 | sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } |
15 | |
16 | =head1 NAME |
17 | |
18 | Data::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 | |
26 | is equivalent to: |
27 | |
28 | use Data::Dumper::Concise; |
29 | |
30 | my @return = some_call(...); |
31 | warn Dumper(@return); |
32 | return @return; |
33 | |
34 | but 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 | |
40 | is equivalent to: |
41 | |
42 | use Data::Dumper::Concise; |
43 | |
44 | my $return = some_call(...); |
45 | warn Dumper($return); |
46 | return $return; |
47 | |
01223632 |
48 | Another trick that is extremely useful when doing method chaining is the |
49 | following: |
50 | |
51 | my $foo = Bar->new; |
52 | $foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff; |
53 | |
54 | which 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 | |
63 | will import Dwarn and DwarnS into your namespace. Using L<Exporter>, so see |
64 | its 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 | |
76 | You probably want L<Devel::Dwarn>, it's the shorter name for this module. |
77 | |
78 | =cut |
ce1f3e8e |
79 | |
80 | 1; |