http://qs321.pair.com?node_id=358735

use Storable; use Fcntl qw(:DEFAULT :flock); sub stash_file{ my($filename,$array)=@_; # $array can be any reference. # I'm not storing in network order now, 'cuz I don't need to. # I will if I need to. sysopen(DF,"$filename", O_RDWR | O_CREAT,0666) or die("Couldn't open $filename: $!"); flock(DF,LOCK_EX) or die("Couldn't lock $filename: $!"); Storable::store_fd($array, *DF) or die("Couldn't store $filename: $!"); truncate(DF, tell(DF)); close(DF); } sub get_file{ my $filename=shift; # This restores the structure and returns it as a reference. open(DF, "< $filename") or die("Couldn't open $filename $!"); flock(DF, LOCK_SH) or die("Couldn't lock $filename $!"); my $doc = Storable::fd_retrieve(\*DF); close(DF); return $doc; }

How to Modify Only Non-Quoted Words?
Nested Categories