in reply to memorizing files and then removing the unnecessary ones

Do you want to do something like
my %myhash=map{$_ => 1}@old_arr ; @new_arr=grep{!$myhash{$_}}@new_arr;

Manav