opendir DH, $dir_to_process # Use a lexical ($dir) instead of a bareword global (DH) if possible #### 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