What I am attempting to do:
Store files and their md5 hash values into a hash, changing the hash when files are added or deleted.
So far I am able to store the md5 hashes and update the hash when files are added.
However I am not sure how to delete the keys for files that are removed
My Approach right now is to:
turn array into a hash to compare
my %files = map { $_ => 1 } @files;
check to see if they are the same
if (%files ~~ %hash).. same.. else... different
I’m not sure how to implement this further.. here is my thinking:
Delete the key in the hash that no longer has a file(pseudo code)
Where exists $hash{$_} && !exists $files{$_} delete $hash{$_}
You don’t need to create hashes to compare lists. Have a look at List::Compare. In particular, the get_unique() and get_complement() methods will identify items which only appear in one of your two lists.