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