in reply to Get a DH from <STDIN>?

Add a chomp($dir_to_process); and it should work. Also you might change the 'print "Cannot...' to 'die "Cannot....'. If you can't open the dir then there is no reason to continue