Author: kwilliams
Date: Thu Sep 27 20:48:37 2007
New Revision: 10009

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm

Log:
Use Data::Dumper in a safer way

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Thu Sep 27 20:48:37 2007
@@ -1,5 +1,8 @@
 Revision history for Perl extension Module::Build.
 
+ - We now use a much more reliable method when Data::Dumper-ing saved
+   state data to the _build/ directory. [Yves]
+
  - When a module had 0.000 as its version, a few places in the code
    thought the module had no version at all.  This is now
    fixed. [Andrew "Zefram" Main]

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Thu Sep 27 20:48:37 2007
@@ -1029,8 +1029,14 @@
   
   my $file = $self->config_file($filename);
   my $fh = IO::File->new("> $file") or die "Can't create '$file': $!";
-  local $Data::Dumper::Terse = 1;
-  print $fh ref($data) ? Data::Dumper::Dumper($data) : $data;
+  unless (ref($data)) {  # e.g. magicnum
+    print $fh $data;
+    return;
+  }
+
+  print $fh ("do{ my "
+            . Data::Dumper->new([$data],['x'])->Purity(1)->Dump()
+            . '$x; }');
 }
 
 sub write_config {

Reply via email to