.\" 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 "Data::Dumper::Concise::Sugar 3pm" .TH Data::Dumper::Concise::Sugar 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" Data::Dumper::Concise::Sugar \- return Dwarn @return_value .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Data::Dumper::Concise::Sugar; \& \& 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 Data::Dumper::Concise::Sugar; \& \& 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 Data::Dumper::Concise::Sugar; \& \& 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 Data::Dumper::Concise::Sugar; \& \& 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 format the output of your data structures, try DwarnF .PP .Vb 1 \& my ($a, $c) = DwarnF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; .Ve .PP is equivalent to: .PP .Vb 3 \& my @return = ($awesome, $cheesy); \& warn DumperF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; \& 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 "DESCRIPTION" .IX Header "DESCRIPTION" .Vb 1 \& use Data::Dumper::Concise::Sugar; .Ve .PP will import Dwarn, \f(CW$Dwarn\fR, DwarnL, DwarnN, and DwarnS into your namespace. Using Exporter, so see its docs for ways to make it do something else. .SS "Dwarn" .IX Subsection "Dwarn" .Vb 1 \& sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } .Ve .ie n .SS "$Dwarn" .el .SS "\f(CW$Dwarn\fP" .IX Subsection "$Dwarn" .Vb 1 \& $Dwarn = \e&Dwarn .Ve .ie n .SS "$DwarnN" .el .SS "\f(CW$DwarnN\fP" .IX Subsection "$DwarnN" .Vb 1 \& $DwarnN = \e&DwarnN .Ve .SS "DwarnL" .IX Subsection "DwarnL" .Vb 1 \& sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ } .Ve .SS "DwarnS" .IX Subsection "DwarnS" .Vb 1 \& sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } .Ve .SS "DwarnN" .IX Subsection "DwarnN" .Vb 1 \& sub DwarnN { warn \*(Aq$argname => \*(Aq . Data::Dumper::Concise::Dumper $_[0]; $_[0] } .Ve .PP \&\fBNote\fR: this requires Devel::ArgNames to be installed. .SS "DwarnF" .IX Subsection "DwarnF" .Vb 1 \& sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } .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 Data::Dumper::Concise::Sugar; \& \& Dwarn ... .Ve .PP We tend to do: .PP .Vb 1 \& perl \-MData::Dumper::Concise::Sugar 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 Data::Dumper::Concise::Sugar\*(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\->Data::Dumper::Concise::Sugar::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" You probably want Devel::Dwarn, it's the shorter name for this module.