in reply to Get a DH from <STDIN>?
The newline is still attached to the directory name. You'll want to
chomp($dir_to_process); [download]
before attempting the opendir.