title: Perl persistent data storage using Data::Dumper
body: <p>I have been trying to figure this out for way to long tonight. I have googled it to death and none of the examples or my hacks of the examples are getting it done. It seems like this should be pretty easy but I just cannot get it. Here is the code:</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  use Data::Dumper;
  
  my $complex_variable = {};
  my $MEMORY = "$ENV{HOME}/data/memory-file";
  
  $complex_variable-&gt;{ 'key' } = 'value';
  $complex_variable-&gt;{ 'key1' } = 'value1';
  $complex_variable-&gt;{ 'key2' } = 'value2';
  $complex_variable-&gt;{ 'key3' } = 'value3';
  
  print Dumper($complex_variable)."TEST001\n";
  
  open M, "&gt;$MEMORY" or die;
  print M Data::Dumper-&gt;Dump([$complex_variable], ['$complex_variable']);
  close M;
  
  $complex_variable = {};
  print Dumper($complex_variable)."TEST002\n";
  
  # Then later to restore the value, it's simply:
  do $MEMORY;
  #eval $MEMORY;
  
  print Dumper($complex_variable)."TEST003\n";   
  </code></pre>
  
  <p>And here is my output:</p>
  
  <pre><code>$VAR1 = {
           'key2' =&gt; 'value2',
           'key1' =&gt; 'value1',
           'key3' =&gt; 'value3',
           'key' =&gt; 'value'
         };
  TEST001
  $VAR1 = {};
  TEST002
  $VAR1 = {};
  TEST003    
  </code></pre>
  
  <p>Everything that I read says that the TEST003 output should look identical to the TEST001 output which is exactly what I am trying to achieve.</p>
  
  <p>What am I missing here? Should I be "do"ing differently or should I be "eval"ing instead and if so how? </p>
  
  <p>Thanks for any help... </p>