bzenker has asked for the wisdom of the Perl Monks concerning the following question:

I have a file with a list of part numbers in it. I need to read in the entire file one line at a time (over 2000 part numbers) and then take that list and find the duplicate numbers in a directory with several subdirectories under it. Once I find the duplicate numbers I have to move the duplicate numbers into a different directory to archive the part numbers. I have some experience in Perl but wanted to ask the experts on some advice before I write the script. Thanks for the help..

Replies are listed 'Best First'.
Re: File/Directory question
by BUU (Prior) on Dec 21, 2004 at 17:01 UTC
    Use <FILE> to read the file, use a %hash to store the part numbers, use File::Find to search through the subdirectories and use File::Copy to move the duplicates.
      Thanks for the quick reply. It makes sense to me.. If I have problems I will post again.

      You probably don't want to run File::Find for every one of your 2000 or so parts. Use it to preload your directory information into some kind of hash structure, then check each part against that structure rather than doing to disk every time.

      Update: duh moment...I'm sure BUU wasn't thinking of running File::Find every time; you just check your hash of part numbers in the 'wanted' subroutine of File::Find, which just gets run once.

      -b