7f32a10f7046ae0bb2ece9d02cadead6eb1a648a
[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   use Data::Dumper::Concise::Sugar;
15
16   return Dwarn some_call(...)
17
18 is equivalent to:
19
20   use Data::Dumper::Concise;
21
22   if (wantarray) {
23      my @return = some_call(...);
24      warn Dumper(@return);
25      return @return;
26   } else {
27      my $return = some_call(...);
28      warn Dumper($return);
29      return $return;
30   }
31
32 but shorter. If you need to force scalar context on the value,
33
34   use Data::Dumper::Concise::Sugar;
35
36   return DwarnS some_call(...)
37
38 is equivalent to:
39
40   use Data::Dumper::Concise;
41
42   my $return = some_call(...);
43   warn Dumper($return);
44   return $return;
45
46 If you need to force list context on the value,
47
48   use Data::Dumper::Concise::Sugar;
49
50   return DwarnL some_call(...)
51
52 is equivalent to:
53
54   use Data::Dumper::Concise;
55
56   my @return = some_call(...);
57   warn Dumper(@return);
58   return @return;
59
60 =head1 TIPS AND TRICKS
61
62 =head2 global usage
63
64 Instead of always just doing:
65
66   use Devel::Dwarn;
67
68   Dwarn ...
69
70 We tend to do:
71
72   perl -MDevel::Dwarn foo.pl
73
74 (and then in the perl code:)
75
76   ::Dwarn ...
77
78 That way, if you leave them in and run without the C<< use Devel::Dwarn >>
79 the program will fail to compile and you are less likely to check it in by
80 accident.  Furthmore it allows that much less friction to add debug messages.
81
82 =head2 method chaining
83
84 One trick which is useful when doing method chaining is the following:
85
86   my $foo = Bar->new;
87   $foo->bar->baz->Devel::Dwarn::DwarnS->biff;
88
89 which is the same as:
90
91   my $foo = Bar->new;
92   (DwarnS $foo->bar->baz)->biff;
93
94 =head1 SEE ALSO
95
96 This module is really just a shortcut for L<Data::Dumper::Concise::Sugar>, check
97 it out for more complete documentation.
98
99 =cut
100
101 1;