create DwarnF for formatting Dumper'd output
[p5sagit/Data-Dumper-Concise.git] / lib / Data / Dumper / Concise.pm
index 0ec1961..5beb1a5 100644 (file)
@@ -9,7 +9,7 @@ require Data::Dumper;
 
 BEGIN { @ISA = qw(Exporter) }
 
-@EXPORT = qw(Dumper);
+@EXPORT = qw(Dumper DumperF);
 
 sub Dumper {
   my $dd = Data::Dumper->new([]);
@@ -17,6 +17,11 @@ sub Dumper {
   return $dd->Values([ @_ ])->Dump;
 }
 
+sub DumperF (&@) {
+  my $code = shift;
+  return $code->(map Dumper($_), @_);
+}
+
 =head1 NAME
 
 Data::Dumper::Concise - Less indentation and newlines plus sub deparsing
@@ -65,6 +70,17 @@ instead of the default Data::Dumper output:
 
 (note the tab indentation, oh joy ...)
 
+Also try out C<DumperF> which takes a C<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);
+
 =head1 DESCRIPTION
 
 This module always exports a single function, Dumper, which can be called