[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[PATCH] Data::Dumper.pm




I've had this one lingering for a while because once again I have
changed jobs. Finally I've managed to take the time to post this.

Below is a quick patch against Data::Dumper 2.101 to make it use the
latest version of B::Deparse to dump CODE references instead of creating
dummy subs.

Comments?

Regards,
James.

-- 
James A. Duncan
Technical Programmer, ebookers.com Plc.
ICQ:     21304370
Email:   james@ebookers.com
Phone:  +44 (0) 207 757 2672 
Mobile: +44 (0) 789 990 5763



--- /usr/local/lib/perl5/5.00558/Data/Dumper.pm	Mon Jan 10 12:28:34 2000
+++ ./Dumper.pm	Mon Jan 10 15:48:01 2000
@@ -19,6 +19,7 @@
 require overload;
 
 use Carp;
+use B::Deparse;
 
 @ISA = qw(Exporter DynaLoader);
 @EXPORT = qw(Dumper);
@@ -334,8 +335,10 @@
       $out .= ($name =~ /^\%/) ? ')' : '}';
     }
     elsif ($realtype eq 'CODE') {
-      $out .= 'sub { "DUMMY" }';
-      carp "Encountered CODE ref, using dummy placeholder" if
$s->{purity};
+      # patched to use B::Deparse's new routines.
+      my $deparse = B::Deparse->new();
+      my $body    = $deparse->coderef2text($val);
+      $out .= 'sub ' . $body;
     }
     else {
       croak "Can\'t handle $realtype type.";


Follow-Ups from:
Chris Nandor <pudge@pobox.com>
Gurusamy Sarathy <gsar@activestate.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]