abcd9cdd30668b8900bd3622139b2fee910e3375
[p5sagit/Data-Dumper-Concise.git] / lib / Devel / Dwarn.pm
1 package Devel::Dwarn;
2
3 use Data::Dumper::Concise::Sugar;
4
5 sub import {
6   Data::Dumper::Concise::Sugar->export_to_level(1, @_);
7 }
8
9 =head1 NAME
10
11 Devel::Dwarn - return Dwarn @return_value
12
13 =head1 SYNOPSIS
14
15   use Devel::Dwarn;
16
17   return Dwarn some_call(...)
18
19 is equivalent to:
20
21   use Data::Dumper::Concise;
22
23   my @return = some_call(...);
24   warn Dumper(@return);
25   return @return;
26
27 but shorter. If you need to force scalar context on the value,
28
29   use Devel::Dwarn;
30
31   return DwarnS some_call(...)
32
33 is equivalent to:
34
35   use Data::Dumper::Concise;
36
37   my $return = some_call(...);
38   warn Dumper($return);
39   return $return;
40
41 Sometimes you'll want to C<Dwarn> out part of a result, instead of the entire
42 thing; for that we have C<Dwarn_only>:
43
44   # Dwarn the TO_JSON of all the objects in the list
45   my @results = Dwarn_only { map $_->TO_JSON, @_ } some_call(...);
46
47 and C<DwarnS_only>:
48
49   # only Dwarn the first item
50   my $data = Dwarn_only { $_->[0] } [ some_call(...) ];
51
52 Another trick that is extremely useful when doing method chaining is the
53 following:
54
55   my $foo = Bar->new;
56   $foo->bar->baz->Devel::Dwarn::DwarnS->biff;
57
58 which is the same as:
59
60   my $foo = Bar->new;
61   (DwarnS $foo->bar->baz)->biff;
62
63 =head1 SEE ALSO
64
65 This module is really just a shortcut for L<Data::Dumper::Concise::Sugar>, check
66 it out for more complete documentation.
67
68 =cut
69
70 1;