G'day keltan,
"Yes this is my homework but i dont need direct answers i appreciate tips."
Thanks for being upfront and honest about that (++).
Here's some tips:
-
Consider using the builtin module Getopt::Long for handling your command line arguments.
-
Consider using the warnings pragma instead of the '-w' switch. The documentation explains why.
-
The rename documentation points out some caveats:
-
The portability issues (rename in perlport) mentions "Win32" — 'D:\test' (in your code) indicates this may be relevant to you.
-
Consider the suggested, platform-independent move() function of the builtin module File::Copy.
-
Avoid package variables for directory handles (DIR in your posted code is an example): these have global scope and suffer from the same problems as all global variables.
Prefer lexical variables whose scope you can control — readdir shows a couple of usage examples.
-
Unrelated to your current question but, for future reference, and for the same reasons, avoid package variables for filehandles — open has examples using lexical filehandles.