in reply to Saving a %hash

As per Tillys comments, using Data::Dumper is one of the ways to go
use Data::Dumper; use Carp; use strict; use warnings; sub write_to_file { my ($file,$data,$small)=@_; open my $OUT,">$file" or croak "Error with $file:$!"; my $dumper=Data::Dumper->new([$data],["my_dump"]); $dumper->Indent($small ? 0 : 2); print $OUT $dumper->Dump; close $OUT; return $dumper->Dump; } sub read_from_file { my $file=shift; local $/; open my $IN,"$file" or croak "Error with $file:$!"; my $data=<$IN>; close $IN; my $my_dump; eval $data; croak "from $file I get error $@" if $@; return $my_dump; } my $test={key=>[qw(this is a list)], subhash=>{qw(so is this one but it must have pairs inside)}} +; write_to_file("test_dumper.dmp",$test); my $var=read_from_file("test_dumper.dmp"); print Dumper($test,$var);
Of course you could use Storable, or Data::Denter or a variety of other methods depending on your needs and space/time/memory requirements. But the type of code above can be a simple way to do configuration files and other simple storage requirements.
Note that there can be security concerns doing this kind of thing with eval.

HTH

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Update I see that I must learn to type faster, or check for replys posted since I started to reply. Nice one Amoe. Or post shorter comments. :-)