in reply to Re^4: Parsing a file and finding the dependencies in it
in thread Parsing a file and finding the dependencies in it

Yes, grep{!$seen{$_}++} just removes duplicates from the list. Perl grep is filtering operation and more powerful than command line grep. It passes the input to the output if the last line of the grep evaluates to "true".

This grep code checks the "truthness" of the seen hash entry for $_. The ! makes it a "not". So this is true if we have not seen a value before. The ++ is a post increment which happens after we've tested for existence. If the key does not already exist, Perl creates it, and allows the undef initial value to be used in the increment. The resulting value is 1 (0+1). If the key already exists it just gets incremented.

The list returned from priorFiles is every possible file that could have affected a particular output file. It contains dupes because some of the input files will share a at least a partial ancestry. priorFiles() is a bit tricky as it calls itself. This is a recursive function and may a bit mind-bending if you haven't seen one before.

I think you are on the way now. Play with the code, insert prints to watch what it does.