I admit I have not tried running your code, but I will make the following suggestions, which I strongly suspect will lead you to your answer:
- when performing a file or directory operation, make sure you test the result, and
- if it fails (especially while still under development) consider looking at the error variable $!.
I say this because I noticed that in your main routine you perform an opendir() and die() on error with a custom error message, ans in your godeep() routine you perform an opendir() and assume success.
Hope that helps.