I wrote a Perl module MySQL::Admin.
No problems with the installer (Module::Build). If I try to install this on Windows I get the message:
saveSettings Permission denied File: C:/strawberry182/cpan/build/MySQL-Admin-0.67-wIbMnp/cgi-bin/config/settings.pl
See the test report for details.
So what is the right "chmod" that a file will be writeable under Windows using Strawberry Perl?
I see in your code a few instances where you're forgetting to close filehandles. Unlike Unix, Windows has automatic, mandatory file locking on open files which can show up as a Permission Denied error when you try to write to a file which is still open. My first suggestion would be to change every use of a global filehandle like
open FILE
toopen my $fh
. Using lexical filehandles means they will automatically close when they go out of scope, greatly reducing the problem.You also no longer need to use
gensym
to create a lexical filehandle,open my $fh
works as far back as 5.6.You're also failing to check that many of your file commands work. flock, seek, truncate... many of them have no checks. You can add checks to all of them, or you can use autodie to quietly add checks for you, or you can use Path::Tiny which will throw exceptions on failure and has many, many convenient file manipulation methods. Just be sure to add them as dependencies in your configure phase.
Second, using
system
on anything but$^X
(the current Perl executable) is going to be non-portable. Replace all of them with equivalent Perl functions. Again, Path::Tiny will come in handy here.Third, Windows permissions are fundamentally different from Unix. Things like chown and chmod and executable bits don't really map. Rule of thumb is you generally don't have to concern yourself with file permissions on Windows.
Finally, get yourself a Windows virtual machine, install Strawberry Perl on it, and test your code. Your code is very Unix-centric, and it will be much faster for you to debug the many small problems it has on Windows than to ask questions of a Windows CPAN tester.