in reply to Delete from array
my %have_file; undef @have_file{glob("*")}; my @dont_exist = grep !exists $have_file{$_}, @should_exist;
On the second line, what I'm using is called a slice. Rather than selecting a single entry from the hash, I select a list - here, the list of filenames returned by glob (of course any other way you get your file names is applicable as well). Then I undef all of these hash entries into existence.
Actually the way I'd write this in my own code is like so:
my @dont_exist = do { my %have_file; undef @have_file{glob("*")}; grep !exists $have_file{$_}, @should_exist; };
Makeshifts last the longest.
|
|---|