I can't comment on any Windows-specific stuff, but I observe that in neither your file-open-for-writing code, nor in the directory-making code, do you check for errors. Any error messages might give a better clue what the issue is.
open my $fh, '>', 'path to windows folder'
or die "Can't open 'path to windows folder': $!\n";
...
mkdir $dirPath,0777
or die "Can't make directory '$dirPath': $!\n";