.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Devel::Dwarn 3pm" .TH Devel::Dwarn 3pm "2017-11-03" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Devel::Dwarn \- Combine warns and Data::Dumper::Concise .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Devel::Dwarn; \& \& return Dwarn some_call(...) .Ve .PP is equivalent to: .PP .Vb 1 \& use Data::Dumper::Concise; \& \& if (wantarray) { \& my @return = some_call(...); \& warn Dumper(@return); \& return @return; \& } else { \& my $return = some_call(...); \& warn Dumper($return); \& return $return; \& } .Ve .PP but shorter. If you need to force scalar context on the value, .PP .Vb 1 \& use Devel::Dwarn; \& \& return DwarnS some_call(...) .Ve .PP is equivalent to: .PP .Vb 1 \& use Data::Dumper::Concise; \& \& my $return = some_call(...); \& warn Dumper($return); \& return $return; .Ve .PP If you need to force list context on the value, .PP .Vb 1 \& use Devel::Dwarn; \& \& return DwarnL some_call(...) .Ve .PP is equivalent to: .PP .Vb 1 \& use Data::Dumper::Concise; \& \& my @return = some_call(...); \& warn Dumper(@return); \& return @return; .Ve .PP If you want to label your output, try DwarnN .PP .Vb 1 \& use Devel::Dwarn; \& \& return DwarnN $foo .Ve .PP is equivalent to: .PP .Vb 1 \& use Data::Dumper::Concise; \& \& my @return = some_call(...); \& warn \*(Aq$foo => \*(Aq . Dumper(@return); \& return @return; .Ve .PP If you want to output a reference returned by a method easily, try \f(CW$Dwarn\fR .PP .Vb 1 \& $foo\->bar\->{baz}\->$Dwarn .Ve .PP is equivalent to: .PP .Vb 3 \& my $return = $foo\->bar\->{baz}; \& warn Dumper($return); \& return $return; .Ve .PP If you want to immediately die after outputting the data structure, every Dwarn subroutine has a paired Ddie version, so just replace the warn with die. For example: .PP .Vb 1 \& DdieL \*(Aqfoo\*(Aq, { bar => \*(Aqbaz\*(Aq }; .Ve .SH "TIPS AND TRICKS" .IX Header "TIPS AND TRICKS" .SS "global usage" .IX Subsection "global usage" Instead of always just doing: .PP .Vb 1 \& use Devel::Dwarn; \& \& Dwarn ... .Ve .PP We tend to do: .PP .Vb 1 \& perl \-MDevel::Dwarn foo.pl .Ve .PP (and then in the perl code:) .PP .Vb 1 \& ::Dwarn ... .Ve .PP That way, if you leave them in and run without the \f(CW\*(C`use Devel::Dwarn\*(C'\fR the program will fail to compile and you are less likely to check it in by accident. Furthmore it allows that much less friction to add debug messages. .SS "method chaining" .IX Subsection "method chaining" One trick which is useful when doing method chaining is the following: .PP .Vb 2 \& my $foo = Bar\->new; \& $foo\->bar\->baz\->Devel::Dwarn::DwarnS\->biff; .Ve .PP which is the same as: .PP .Vb 2 \& my $foo = Bar\->new; \& (DwarnS $foo\->bar\->baz)\->biff; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" This module is really just a shortcut for Data::Dumper::Concise::Sugar, check it out for more complete documentation.