Data-Dumper-Concise-2.023/000700 000766 000024 00000000000 13105370076 015447 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/Changes000644 000766 000024 00000003050 13105367750 016757 0ustar00etherstaff000000 000000 Revision history for Data-Dumper-Concise 2.023 - 2017-05-12 - convert distribution from Module::Install to Distar; fixes RT#120856 - every module has a $VERSION now (RT#116427) - add support for Trailingcomma option (RT#114609, Aaron Crane) 2.022 Mar 21 2014 - Fix repo metadata 2.021 Dec 31 2013 - Make Dwarn output all arguments even in scalar context (retun val is still the same though) 2.020 Jan 20 2011 - Add DumperObject for getting at the underlying obj - create DwarnF for formatting Dumper'd output - Create Ddie for die'ing output 2.012 Aug 31 2010 - Make DwarnN test still work if Devel::ArgNames isn't installed 2.011 Aug 30 2010 - add $DwarnN export - make Devel::ArgNames an optional dep 2.010 Jul 29 2010 - add $Dwarn export 2.001 Jul 23 2010 - add documentation for DwarnN 2.000 Jul 22 2010 - remove Dumper() returning object - add DwarnN - add DwarnL - make Dwarn contextual - document ::Dwarn idiom 1.200 Feb 13 2010 - make sure Devel::Dwarn::Dwarn and Devel::Dwarn::DwarnS work 1.100 Dec 10 2009 - add Data::Dumper::Concise::Sugar containing Dwarn and DwarnS helper functions - add Devel::Dwarn as a more concise alias for ::Sugar 1.002 Nov 22 2009 - open up non-ref and multiple arguments since I've not seen any other viable use for the additional syntax 1.001 Oct 5 2009 - more explanation of purpose, limitations and alternatives in the POD 1.000 Oct 3 2009 - Dumper() returns concise Data::Dumper object - Dumper($ref) returns concisely dumped ref - anything else die()s Data-Dumper-Concise-2.023/MANIFEST000644 000766 000024 00000000620 13105370076 016610 0ustar00etherstaff000000 000000 Changes lib/Data/Dumper/Concise.pm lib/Data/Dumper/Concise/Sugar.pm lib/Devel/Dwarn.pm Makefile.PL MANIFEST This list of files t/concise.t t/dwarn.t t/sugar.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) Data-Dumper-Concise-2.023/META.json000600 000766 000024 00000003126 13105370076 017074 0ustar00etherstaff000000 000000 { "abstract" : "Less indentation and newlines plus sub deparsing", "author" : [ "mst - Matt S. Trout (cpan:MSTROUT) " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.2501, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Data-Dumper-Concise", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Data::Dumper" : "0", "Exporter" : "0", "perl" : "5.006" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Data-Dumper-Concise@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dumper-Concise" }, "repository" : { "type" : "git", "url" : "https://github.com/p5sagit/Data-Dumper-Concise.git", "web" : "https://github.com/p5sagit/Data-Dumper-Concise" } }, "version" : "2.023", "x_contributors" : [ "Arthur Axel 'fREW' Schmidt ", "Matt S Trout ", "Karen Etheridge " ], "x_serialization_backend" : "JSON::MaybeXS version 1.003009" } Data-Dumper-Concise-2.023/META.yml000600 000766 000024 00000001670 13105370076 016726 0ustar00etherstaff000000 000000 --- abstract: 'Less indentation and newlines plus sub deparsing' author: - 'mst - Matt S. Trout (cpan:MSTROUT) ' build_requires: Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.2501, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Data-Dumper-Concise no_index: directory: - t - inc requires: Data::Dumper: '0' Exporter: '0' perl: '5.006' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dumper-Concise repository: https://github.com/p5sagit/Data-Dumper-Concise.git version: '2.023' x_contributors: - "Arthur Axel 'fREW' Schmidt " - 'Matt S Trout ' - 'Karen Etheridge ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Data-Dumper-Concise-2.023/Makefile.PL000644 000766 000024 00000006015 13105364247 017440 0ustar00etherstaff000000 000000 use strict; use warnings FATAL => 'all'; use ExtUtils::MakeMaker; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; my %WriteMakefileArgs = ( NAME => 'Data::Dumper::Concise', VERSION_FROM => 'lib/Data/Dumper/Concise.pm', META_MERGE => { 'meta-spec' => { version => 2 }, dynamic_config => 0, resources => { # GitHub mirrors from Shadowcat. We list it so we can get pull requests. # The canonical repo is: # r/o: git://git.shadowcat.co.uk/p5sagit/Data-Dumper-Concise.git # r/w: p5sagit@git.shadowcat.co.uk:Data-Dumper-Concise.git # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Data-Dumper-Concise.git repository => { url => 'https://github.com/p5sagit/Data-Dumper-Concise.git', web => 'https://github.com/p5sagit/Data-Dumper-Concise', type => 'git', }, bugtracker => { mailto => 'bug-Data-Dumper-Concise@rt.cpan.org', web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dumper-Concise', }, }, x_contributors => [ # manually added, from git shortlog -e -s -n 'Arthur Axel \'fREW\' Schmidt ', 'Matt S Trout ', 'Karen Etheridge ', ], }, META_ADD => { 'meta-spec' => { version => 2 }, prereqs => { configure => { requires => { 'ExtUtils::MakeMaker' => '0', }, }, runtime => { requires => { 'Exporter' => '0', 'Data::Dumper' => '0', 'perl' => '5.006', }, }, test => { requires => { 'Test::More' => '0', }, }, }, }, ); my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; for (qw(configure build test runtime)) { my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; next unless exists $WriteMakefileArgs{META_ADD}{prereqs}{$_} or exists $WriteMakefileArgs{$key}; my $r = $WriteMakefileArgs{$key} = { %{$WriteMakefileArgs{META_ADD}{prereqs}{$_}{requires} || {}}, %{delete $WriteMakefileArgs{$key} || {}}, }; defined $r->{$_} or delete $r->{$_} for keys %$r; } # dynamic prereqs get added here... $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0; die 'attention developer: you need to do a sane meta merge here!' if keys %{$WriteMakefileArgs{BUILD_REQUIRES}}; $WriteMakefileArgs{BUILD_REQUIRES} = { %{$WriteMakefileArgs{BUILD_REQUIRES} || {}}, %{delete $WriteMakefileArgs{TEST_REQUIRES}} } if $eumm_version < 6.63_03; $WriteMakefileArgs{PREREQ_PM} = { %{$WriteMakefileArgs{PREREQ_PM}}, %{delete $WriteMakefileArgs{BUILD_REQUIRES}} } if $eumm_version < 6.55_01; delete $WriteMakefileArgs{CONFIGURE_REQUIRES} if $eumm_version < 6.51_03; delete $WriteMakefileArgs{MIN_PERL_VERSION} if $eumm_version < 6.48; delete @WriteMakefileArgs{qw(META_ADD META_MERGE)} if $eumm_version < 6.46; delete $WriteMakefileArgs{LICENSE} if $eumm_version < 6.31; WriteMakefile(%WriteMakefileArgs); Data-Dumper-Concise-2.023/README000600 000766 000024 00000007723 13105370076 016342 0ustar00etherstaff000000 000000 NAME Data::Dumper::Concise - Less indentation and newlines plus sub deparsing SYNOPSIS use Data::Dumper::Concise; warn Dumper($var); is equivalent to: use Data::Dumper; { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Trailingcomma = 1; warn Dumper($var); } So for the structure: { foo => "bar\nbaz", quux => sub { "fleem" } }; Data::Dumper::Concise will give you: { foo => "bar\nbaz", quux => sub { use warnings; use strict 'refs'; 'fleem'; }, } instead of the default Data::Dumper output: $VAR1 = { 'quux' => sub { "DUMMY" }, 'foo' => 'bar baz' }; (note the tab indentation, oh joy ...) (The trailing comma on the last element of an array or hash is enabled by a new feature in Data::Dumper version 2.159, which was first released in Perl 5.24. Using Data::Dumper::Concise with an older version of Data::Dumper will still work, but you won't get those commas.) If you need to get the underlying Dumper object just call "DumperObject". Also try out "DumperF" which takes a "CodeRef" as the first argument to format the output. For example: use Data::Dumper::Concise; warn DumperF { "result: $_[0] result2: $_[1]" } $foo, $bar; Which is the same as: warn 'result: ' . Dumper($foo) . ' result2: ' . Dumper($bar); DESCRIPTION This module always exports a single function, Dumper, which can be called with an array of values to dump those values. It exists, fundamentally, as a convenient way to reproduce a set of Dumper options that we've found ourselves using across large numbers of applications, primarily for debugging output. The principle guiding theme is "all the concision you can get while still having a useful dump and not doing anything cleverer than setting Data::Dumper options" - it's been pointed out to us that Data::Dump::Streamer can produce shorter output with less lines of code. We know. This is simpler and we've never seen it segfault. But for complex/weird structures, it generally rocks. You should use it as well, when Concise is underkill. We do. Why is deparsing on when the aim is concision? Because you often want to know what subroutine refs you have when debugging and because if you were planning to eval this back in you probably wanted to remove subrefs first and add them back in a custom way anyway. Note that this -does- force using the pure perl Dumper rather than the XS one, but I've never in my life seen Data::Dumper show up in a profile so "who cares?". BUT BUT BUT ... Yes, we know. Consider this module in the ::Tiny spirit and feel free to write a Data::Dumper::Concise::ButWithExtraTwiddlyBits if it makes you happy. Then tell us so we can add it to the see also section. SUGARY SYNTAX This package also provides: Data::Dumper::Concise::Sugar - provides Dwarn and DwarnS convenience functions Devel::Dwarn - shorter form for Data::Dumper::Concise::Sugar SEE ALSO We use for some purposes, and dearly love, the following alternatives: Data::Dump - prettiness oriented but not amazingly configurable Data::Dump::Streamer - brilliant. beautiful. insane. extensive. excessive. try it. JSON::XS - no, really. If it's just plain data, JSON is a great option. AUTHOR mst - Matt S. Trout CONTRIBUTORS frew - Arthur Axel "fREW" Schmidt COPYRIGHT Copyright (c) 2010 the Data::Dumper::Concise "AUTHOR" and "CONTRIBUTORS" as listed above. LICENSE This library is free software and may be distributed under the same terms as perl itself. Data-Dumper-Concise-2.023/lib/000700 000766 000024 00000000000 13105370076 016215 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/t/000700 000766 000024 00000000000 13105370076 015712 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/t/concise.t000644 000766 000024 00000002464 13105365660 017545 0ustar00etherstaff000000 000000 use strict; use warnings; use Data::Dumper (); use Data::Dumper::Concise; use Test::More qw(no_plan); my $dd = Data::Dumper->new([]) ->Terse(1) ->Indent(1) ->Useqq(1) ->Deparse(1) ->Quotekeys(0) ->Sortkeys(1); $dd->Trailingcomma(1) if $dd->can('Trailingcomma'); foreach my $to_dump ( [ { foo => "bar\nbaz", quux => sub { "fleem" } } ], [ 'one', 'two' ] ) { $dd->Values([ @$to_dump ]); my $example = do { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; no warnings 'once'; # in case Trailingcomma option is unknown in this DD local $Data::Dumper::Trailingcomma = 1; Data::Dumper::Dumper(@$to_dump); }; is($example, $dd->Dump, 'Both Data::Dumper usages equivalent'); is($example, Dumper(@$to_dump), 'Subroutine call usage equivalent'); } my $out = DumperF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl"; like($out, qr{^arr: \[\n "wut",\n "HALP",?\n\]\n str: "gnarl"\n\z}, 'DumperF works!'); like(Dumper([1..3]), qr/,\s*]\s*$/, 'trailing comma enabled') if $dd->can('Trailingcomma'); Data-Dumper-Concise-2.023/t/dwarn.t000644 000766 000024 00000000401 13105363470 017217 0ustar00etherstaff000000 000000 use strict; use warnings; use Devel::Dwarn; use Test::More qw(no_plan); can_ok __PACKAGE__, qw{Dwarn DwarnS DwarnL DwarnN}; can_ok 'Devel::Dwarn', qw{Dwarn DwarnS DwarnL DwarnN}; ok($Dwarn, '$Dwarn gets exported'); ok($DwarnN, '$DwarnN gets exported'); Data-Dumper-Concise-2.023/t/sugar.t000644 000766 000024 00000003645 13105365660 017245 0ustar00etherstaff000000 000000 use strict; use warnings; use Data::Dumper::Concise::Sugar; use Data::Dumper::Concise (); use Test::More qw(no_plan); my $warned_string; BEGIN { $SIG{'__WARN__'} = sub { $warned_string = $_[0] } } DWARNL: { my @foo = DwarnL 'warn', 'friend'; is $warned_string,qq{"warn"\n"friend"\n}, 'DwarnL warns'; ok eq_array(\@foo, ['warn','friend']), 'DwarnL passes through correctly'; } DWARNS: { my $bar = DwarnS 'robot',2,3; is $warned_string,qq{"robot"\n}, 'DwarnS warns'; is $bar, 'robot', 'DwarnS passes through correctly'; } DWARN: { my @foo = Dwarn 'warn', 'friend'; is $warned_string,qq{"warn"\n"friend"\n}, 'Dwarn warns lists'; ok eq_array(\@foo, ['warn','friend']), 'Dwarn passes lists through correctly'; my $bar = Dwarn 'robot',2,3; is $warned_string,qq{"robot"\n2\n3\n}, 'Dwarn warns scalars correctly'; is $bar, 'robot', 'Dwarn passes scalars through correctly'; } DWARN_CODEREF: { my $foo = ['warn', 'friend']->$Dwarn; like $warned_string,qr{^\[\n "warn",\n "friend",?\n\]\n\z}, 'Dwarn warns lists'; ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly'; } DWARNF: { my @foo = DwarnF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl"; like($warned_string, qr{^arr: \[\n "wut",\n "HALP",?\n\]\n str: "gnarl"\n\z}, 'DumperF works!'); ok eq_array($foo[0], ['wut','HALP']) && $foo[1] eq 'gnarl', 'DwarnF passes lists through correctly'; } DWARNN: { my $loaded = eval { require Devel::ArgNames; 1 }; if ($loaded) { my $x = [1]; my $foo = DwarnN $x; like $warned_string, qr{^\$x => \[\n 1,?\n\]\n\z}, 'DwarnN warns'; ok eq_array($foo, [1]), 'DwarnN passes through correctly'; DwarnN [1]; like $warned_string, qr{^\(anon\) => \[\n 1,?\n\]\n\z}, 'DwarnN warns'; } } DDIE: { eval { DdieS [ 'k', 'bar' ]; }; like $@, qr{^\[\n "k",\n "bar",?\n\]\n\z}, 'DwarnD dies output correctly'; } Data-Dumper-Concise-2.023/lib/Data/000700 000766 000024 00000000000 13105370076 017066 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/lib/Devel/000700 000766 000024 00000000000 13105370076 017254 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/lib/Devel/Dwarn.pm000644 000766 000024 00000004571 13105363470 020706 0ustar00etherstaff000000 000000 package Devel::Dwarn; use Data::Dumper::Concise::Sugar; sub import { Data::Dumper::Concise::Sugar->export_to_level(1, @_); } =head1 NAME Devel::Dwarn - Combine warns and Data::Dumper::Concise =head1 SYNOPSIS use Devel::Dwarn; return Dwarn some_call(...) is equivalent to: 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; } but shorter. If you need to force scalar context on the value, use Devel::Dwarn; return DwarnS some_call(...) is equivalent to: use Data::Dumper::Concise; my $return = some_call(...); warn Dumper($return); return $return; If you need to force list context on the value, use Devel::Dwarn; return DwarnL some_call(...) is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn Dumper(@return); return @return; If you want to label your output, try DwarnN use Devel::Dwarn; return DwarnN $foo is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn '$foo => ' . Dumper(@return); return @return; If you want to output a reference returned by a method easily, try $Dwarn $foo->bar->{baz}->$Dwarn is equivalent to: my $return = $foo->bar->{baz}; warn Dumper($return); return $return; 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: DdieL 'foo', { bar => 'baz' }; =head1 TIPS AND TRICKS =head2 global usage Instead of always just doing: use Devel::Dwarn; Dwarn ... We tend to do: perl -MDevel::Dwarn foo.pl (and then in the perl code:) ::Dwarn ... That way, if you leave them in and run without the C<< use Devel::Dwarn >> 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. =head2 method chaining One trick which is useful when doing method chaining is the following: my $foo = Bar->new; $foo->bar->baz->Devel::Dwarn::DwarnS->biff; which is the same as: my $foo = Bar->new; (DwarnS $foo->bar->baz)->biff; =head1 SEE ALSO This module is really just a shortcut for L, check it out for more complete documentation. =cut 1; Data-Dumper-Concise-2.023/lib/Data/Dumper/000700 000766 000024 00000000000 13105370076 020322 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/lib/Data/Dumper/Concise/000700 000766 000024 00000000000 13105370076 021705 5ustar00etherstaff000000 000000 Data-Dumper-Concise-2.023/lib/Data/Dumper/Concise.pm000644 000766 000024 00000010371 13105365660 022262 0ustar00etherstaff000000 000000 package Data::Dumper::Concise; use 5.006; our $VERSION = '2.023'; require Exporter; require Data::Dumper; BEGIN { @ISA = qw(Exporter) } @EXPORT = qw(Dumper DumperF DumperObject); sub DumperObject { my $dd = Data::Dumper->new([]); $dd->Trailingcomma(1) if $dd->can('Trailingcomma'); $dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1); } sub Dumper { DumperObject->Values([ @_ ])->Dump } sub DumperF (&@) { my $code = shift; return $code->(map Dumper($_), @_); } =head1 NAME Data::Dumper::Concise - Less indentation and newlines plus sub deparsing =head1 SYNOPSIS use Data::Dumper::Concise; warn Dumper($var); is equivalent to: use Data::Dumper; { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Trailingcomma = 1; warn Dumper($var); } So for the structure: { foo => "bar\nbaz", quux => sub { "fleem" } }; Data::Dumper::Concise will give you: { foo => "bar\nbaz", quux => sub { use warnings; use strict 'refs'; 'fleem'; }, } instead of the default Data::Dumper output: $VAR1 = { 'quux' => sub { "DUMMY" }, 'foo' => 'bar baz' }; (note the tab indentation, oh joy ...) (The trailing comma on the last element of an array or hash is enabled by a new feature in Data::Dumper version 2.159, which was first released in Perl 5.24. Using Data::Dumper::Concise with an older version of Data::Dumper will still work, but you won't get those commas.) If you need to get the underlying L object just call C. Also try out C which takes a C as the first argument to format the output. For example: use Data::Dumper::Concise; warn DumperF { "result: $_[0] result2: $_[1]" } $foo, $bar; Which is the same as: warn 'result: ' . Dumper($foo) . ' result2: ' . Dumper($bar); =head1 DESCRIPTION This module always exports a single function, Dumper, which can be called with an array of values to dump those values. It exists, fundamentally, as a convenient way to reproduce a set of Dumper options that we've found ourselves using across large numbers of applications, primarily for debugging output. The principle guiding theme is "all the concision you can get while still having a useful dump and not doing anything cleverer than setting Data::Dumper options" - it's been pointed out to us that Data::Dump::Streamer can produce shorter output with less lines of code. We know. This is simpler and we've never seen it segfault. But for complex/weird structures, it generally rocks. You should use it as well, when Concise is underkill. We do. Why is deparsing on when the aim is concision? Because you often want to know what subroutine refs you have when debugging and because if you were planning to eval this back in you probably wanted to remove subrefs first and add them back in a custom way anyway. Note that this -does- force using the pure perl Dumper rather than the XS one, but I've never in my life seen Data::Dumper show up in a profile so "who cares?". =head1 BUT BUT BUT ... Yes, we know. Consider this module in the ::Tiny spirit and feel free to write a Data::Dumper::Concise::ButWithExtraTwiddlyBits if it makes you happy. Then tell us so we can add it to the see also section. =head1 SUGARY SYNTAX This package also provides: L - provides Dwarn and DwarnS convenience functions L - shorter form for Data::Dumper::Concise::Sugar =head1 SEE ALSO We use for some purposes, and dearly love, the following alternatives: L - prettiness oriented but not amazingly configurable L - brilliant. beautiful. insane. extensive. excessive. try it. L - no, really. If it's just plain data, JSON is a great option. =head1 AUTHOR mst - Matt S. Trout =head1 CONTRIBUTORS frew - Arthur Axel "fREW" Schmidt =head1 COPYRIGHT Copyright (c) 2010 the Data::Dumper::Concise L and L as listed above. =head1 LICENSE This library is free software and may be distributed under the same terms as perl itself. =cut 1; Data-Dumper-Concise-2.023/lib/Data/Dumper/Concise/Sugar.pm000644 000766 000024 00000010743 13105365557 023353 0ustar00etherstaff000000 000000 package Data::Dumper::Concise::Sugar; use 5.006; our $VERSION = '2.023'; use Exporter (); use Data::Dumper::Concise (); BEGIN { @ISA = qw(Exporter) } @EXPORT = qw( $Dwarn $DwarnN Dwarn DwarnS DwarnL DwarnN DwarnF $Ddie $DdieN Ddie DdieS DdieL DdieN DdieD ); sub Dwarn { DwarnL(@_); return wantarray ? @_ : $_[0] } our $Dwarn = \&Dwarn; our $DwarnN = \&DwarnN; sub DwarnL { warn Data::Dumper::Concise::Dumper @_; @_ } sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } sub DwarnN ($) { require Devel::ArgNames; my $x = Devel::ArgNames::arg_names(); warn(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]); $_[0] } sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } sub Ddie { DdieL(@_); return wantarray ? @_ : $_[0] } our $Ddie = \&Ddie; our $DdieN = \&DdieN; sub DdieL { die Data::Dumper::Concise::Dumper @_ } sub DdieS ($) { die Data::Dumper::Concise::Dumper $_[0] } sub DdieN ($) { require Devel::ArgNames; my $x = Devel::ArgNames::arg_names(); die(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]); } =head1 NAME Data::Dumper::Concise::Sugar - return Dwarn @return_value =head1 SYNOPSIS use Data::Dumper::Concise::Sugar; return Dwarn some_call(...) is equivalent to: 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; } but shorter. If you need to force scalar context on the value, use Data::Dumper::Concise::Sugar; return DwarnS some_call(...) is equivalent to: use Data::Dumper::Concise; my $return = some_call(...); warn Dumper($return); return $return; If you need to force list context on the value, use Data::Dumper::Concise::Sugar; return DwarnL some_call(...) is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn Dumper(@return); return @return; If you want to label your output, try DwarnN use Data::Dumper::Concise::Sugar; return DwarnN $foo is equivalent to: use Data::Dumper::Concise; my @return = some_call(...); warn '$foo => ' . Dumper(@return); return @return; If you want to output a reference returned by a method easily, try $Dwarn $foo->bar->{baz}->$Dwarn is equivalent to: my $return = $foo->bar->{baz}; warn Dumper($return); return $return; If you want to format the output of your data structures, try DwarnF my ($a, $c) = DwarnF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; is equivalent to: my @return = ($awesome, $cheesy); warn DumperF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy; return @return; 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: DdieL 'foo', { bar => 'baz' }; =head1 DESCRIPTION use Data::Dumper::Concise::Sugar; will import Dwarn, $Dwarn, DwarnL, DwarnN, and DwarnS into your namespace. Using L, so see its docs for ways to make it do something else. =head2 Dwarn sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } =head2 $Dwarn $Dwarn = \&Dwarn =head2 $DwarnN $DwarnN = \&DwarnN =head2 DwarnL sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ } =head2 DwarnS sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] } =head2 DwarnN sub DwarnN { warn '$argname => ' . Data::Dumper::Concise::Dumper $_[0]; $_[0] } B: this requires L to be installed. =head2 DwarnF sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } =head1 TIPS AND TRICKS =head2 global usage Instead of always just doing: use Data::Dumper::Concise::Sugar; Dwarn ... We tend to do: perl -MData::Dumper::Concise::Sugar foo.pl (and then in the perl code:) ::Dwarn ... That way, if you leave them in and run without the C<< use Data::Dumper::Concise::Sugar >> 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. =head2 method chaining One trick which is useful when doing method chaining is the following: my $foo = Bar->new; $foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff; which is the same as: my $foo = Bar->new; (DwarnS $foo->bar->baz)->biff; =head1 SEE ALSO You probably want L, it's the shorter name for this module. =cut 1;