Storable makes this much easier than Data::Dumper. Here's a sample using Data::Dumper:
#!/usr/bin/perl -w
use Data::Dumper;
my %hash = ('foo' => 'bar',
'camel' => 'beast',
'bug' => 'spray');
#dump the structure
open (FILE, '>/tmp/hash') or die "$!\n";
print FILE Dumper(\%hash);
close FILE;
#recreate the structure
open (FILE,'/tmp/hash') or die "$!\n";
my $data = do { local $/; <FILE> };
my %newhash = %{eval $data};
And here's the same thing with Storable:
use Storable;
store \%hash, '/tmp/hash';
my %newhash = %{retrieve('file')};
BlueLines
Disclaimer:
This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.