use Data::Dumper;
# create a hashref
my $hash = {};
# load the hash keys from a file
$hash = do "./data.txt" if -f "./data.txt";
# modify the hash or whatnot...
$hash->{$filename} = 1;
$hash->{$another_filename} = 1;
# save it to a file again
open (DATA, ">./data.txt");
print DATA Dumper($hash);
close (DATA);
It should work the same with normal hashes (ie the $hash{$filename} format, without the arrows), you'd probably change the $hash=do line to %hash=do... I like working with hashrefs though for the little arrows between keys, it makes it easy to read
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.