in reply to Re^3: create array of empty files and then match filenames
in thread create array of empty files and then match filenames

Do you need a foreach loop ?.
You are checking the same value of $previous regardless of the loop variable $_

poj