sub Clone { my $donor = shift; my $file = shift; my ( $dna, $clone ); local $Data::Dumper::Indent = 0; # It will be eval'd, we don't need pretty local $Data::Dumper::Purity = 1; # make sure all code is present local $Data::Dumper::Terse = 1; # makes the eval work well local $Data::Dumper::Deepcopy = 1; # tell Dumper our intent #--- # Interestingly enough, Dumper will embed the call to bless in the DNA. # Which makes this whole analogy really quite accurate and somehow strange #--- $dna = Dumper( $donor ); #--- # At this point, the data structure in $donor is stringified # into $dna. $dna can be written to file or whatever. # To get it back out, do something like what follows - # this is a cloning function, after all. #--- $clone = eval $dna; return $clone; }