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);

before attempting the opendir.