in reply to Get a DH from <STDIN>?

When opendir fails, you should die and examine the error message.
opendir(DH, $dir_to_process) or die "Cannot open $dir_to_process: $!";
Most likely you just need to chomp your input string
my $dir_to_process = <STDIN>; chomp $dir_to_process;