Save hash value to a file
%hash = (
meat => turkey,
drink => tea,
cheese => colby,
);
open FILEHANDLE, ">hash.dat" or die "Can not open hash.dat";
$, = " ";
print FILEHANDLE %hash;
close FILEHANDLE;
open FILEHANDLE2, "<hash.dat" or die "Can not open hash.dat";
%hash2 = split(" ", <FILEHANDLE2>);
close FILEHANDLE2;
foreach $key (keys %hash2) {
print "$key => $hash2{$key}\n";
}
Related examples in the same category