##
if ($file =~ /\.txt$/)
# This would break for a directory called dir.txt - see perldoc -f -X
####
%stuff_to_store = ($dir_to_process, $file);
# This overwrites the hash entirely every time
####
while (%stuff_to_store) {
# this will be an infinite loop if the hash contains any items