in reply to Re^3: Compare 2 arrays
in thread Compare 2 arrays

Looks like the keepList hash is not being populated correctly. I tweaked the code a bit in my post. See how you do with the modifications. I added a print statement. Make sure that it is printing correctly the files that should be kept!

Update: Another point, when you run the code warnings matter! My previous code with while (<$namesIn>) would have produced a warning if not an outright failure because $line was not declared! The new code, while (my $line = <$namesIn>) "should work". This kind of error is common in untested code. I would have expected that you find that and fix it on your own.

When debugging code, "print" is your best friend. Add more print statements to see what the code is actually doing. I put in one for the keepList hash because I suspect that is where the problem lies. Add another one before the unlink to see what is going on there. The Perl debugger is also helpful, but print works so well that I seldom need to resort to that even when I am writing C code.

First, debug the code that reads the SDF file and gets the .nfo file names. Then debug the code that does the unlink (i.e. delete in Windows lingo).