X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FData-Dumper-Concise.git;a=blobdiff_plain;f=lib%2FData%2FDumper%2FConcise%2FSugar.pm;h=5aef1a1ea7824fddbedd39cfcc124cf4e0bd7096;hp=4b33717b0749b3fd6437d46870fdf380aae8c114;hb=92264889a0f278aa61cdee48aef484496fb6e5ce;hpb=452e7ff29c95f7771bf5efd31c24cfb6f2d7b2bb diff --git a/lib/Data/Dumper/Concise/Sugar.pm b/lib/Data/Dumper/Concise/Sugar.pm index 4b33717..5aef1a1 100644 --- a/lib/Data/Dumper/Concise/Sugar.pm +++ b/lib/Data/Dumper/Concise/Sugar.pm @@ -7,7 +7,7 @@ use Data::Dumper::Concise (); BEGIN { @ISA = qw(Exporter) } -@EXPORT = qw($Dwarn $DwarnN Dwarn DwarnS DwarnL DwarnN); +@EXPORT = qw($Dwarn $DwarnN Dwarn DwarnS DwarnL DwarnN DwarnF); sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) } @@ -24,6 +24,8 @@ sub DwarnN ($) { warn(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]); $_[0] } +sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ } + =head1 NAME Data::Dumper::Concise::Sugar - return Dwarn @return_value @@ -100,6 +102,16 @@ is equivalent to: 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; + =head1 DESCRIPTION use Data::Dumper::Concise::Sugar; @@ -133,6 +145,10 @@ L, so see its docs for ways to make it do something else. 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