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).


In reply to Re^4: Compare 2 arrays by Marshall
in thread Compare 2 arrays by niceguy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.