]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex/Dump.pm
add PSGI handler
[chaz/p5-CGI-Ex] / lib / CGI / Ex / Dump.pm
index c4d49f977f3d7d71ad25167eb0f40704129c636f..d3f84b43cd76de1e94506adfdddef4366ef517b9 100644 (file)
@@ -7,40 +7,40 @@ CGI::Ex::Dump - A debug utility
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2004-2012 - Paul Seamons                                #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
 use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION
             $CALL_LEVEL
-            $ON $SUB $QR1 $QR2 $full_filename);
+            $ON $SUB $QR1 $QR2 $full_filename $DEPARSE);
 use strict;
 use Exporter;
 
-$VERSION   = '2.04';
+$VERSION   = '2.37';
 @ISA       = qw(Exporter);
 @EXPORT    = qw(dex dex_warn dex_text dex_html ctrace dex_trace);
-@EXPORT_OK = qw(dex dex_warn dex_text dex_html ctrace dex_trace debug);
+@EXPORT_OK = qw(dex dex_warn dex_text dex_html ctrace dex_trace debug caller_trace);
 
 ### is on or off
 sub on  { $ON = 1 };
 sub off { $ON = 0; }
-&on();
 
-sub set_deparse {
-  $Data::Dumper::Deparse = eval {require B::Deparse};
-}
+sub set_deparse { $DEPARSE = 1 }
 
 ###----------------------------------------------------------------###
 
 BEGIN {
-  ### setup the Data::Dumper usage
-  $Data::Dumper::Sortkeys  = 1    if ! defined $Data::Dumper::Sortkeys; # not avail pre 5.8
-  $Data::Dumper::Useqq     = 1    if ! defined $Data::Dumper::Useqq;
-  $Data::Dumper::Quotekeys = 0    if ! defined $Data::Dumper::Quotekeys;
-  $Data::Dumper::Pad       = '  ' if ! defined $Data::Dumper::Pad;
-  #$Data::Dumper::Deparse   = 1    if ! defined $Data::Dumper::Deparse; # very useful
+  on();
+
   $SUB = sub {
+    ### setup the Data::Dumper usage
+    local $Data::Dumper::Deparse   = $DEPARSE && eval {require B::Deparse};
+    local $Data::Dumper::Pad       = '  ';
+    local $Data::Dumper::Sortkeys  = 1;
+    local $Data::Dumper::Useqq     = 1;
+    local $Data::Dumper::Quotekeys = 0;
+
     require Data::Dumper;
     return Data::Dumper->Dumpperl(\@_);
   };
@@ -102,7 +102,7 @@ sub _what_is_this {
   } else {
     my $html = "<pre class=debug><span class=debughead><b>$called: $file line $line_n</b></span>\n";
     for (0 .. $#dump) {
-      $dump[$_] =~ s/\\n/\n/g;
+      $dump[$_] =~ s/(?<!\\)\\n/\n/g;
       $dump[$_] = _html_quote($dump[$_]);
       $dump[$_] =~ s|\$VAR1|<span class=debugvar><b>$var[$_]</b></span>|g;
       $html .= $dump[$_];
@@ -111,8 +111,9 @@ sub _what_is_this {
     return $html if $called eq 'dex_html';
     require CGI::Ex;
     CGI::Ex::print_content_type();
-    print $html;
+    ($CGI::Ex::CURRENT || CGI::Ex->new)->print_body($html);
   }
+  return @_[0..$#_];
 }
 
 ### some aliases
@@ -160,6 +161,8 @@ sub ctrace {
   return \@i;
 }
 
+*caller_trace = \&ctrace;
+
 sub dex_trace {
   _what_is_this(ctrace(1));
 }
@@ -239,8 +242,12 @@ Turns calls to routines on or off.  Default is to be on.
 
 =back
 
+=head1 LICENSE
+
+This module may distributed under the same terms as Perl itself.
+
 =head1 AUTHORS
 
-Paul Seamons <perlspam at seamons dot com>
+Paul Seamons <perl at seamons dot com>
 
 =cut
This page took 0.022947 seconds and 4 git commands to generate.