sara2005 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am trying to use CGI:Session for data persistence and with help from you, I was able to successfully test on Apache installed on Unix. But, when I tried to test the same on Apache installed in windows,I get the following error message:-

\t(in cleanup) flock() unimplemented on this platform at C:\\perllib/C +GI/Session/Driver/

Any suggestions as to why I get this error? Would appreciate your help..

2006-05-25 Retitled by GrandFather, as per Monastery guidelines
Original title: 'CGI:Session'

Replies are listed 'Best First'.
Re: Error in CGI::Session on Windows: flock() not implemented
by antirice (Priest) on Dec 12, 2005 at 21:02 UTC

    Just curious but which version of windows are you running?

    I just added an option to svn that allows you to disable file locking. It should be available in the next release of CGI::Session.

      Windows 98SE.

      Do you think it could be the reason why it is not supported?

        According to perlport, seems to be. I don't think windows supports flock until you get into the NT's (2000, XP, etc).

        For the time being, you could add the following code to your script to override flock. (NOTE: Only do this for when you run on Windows 98 as the locks are very important with a filesystem that allows concurrent access to files).

        BEGIN { *CORE::GLOBAL::flock = sub { return 1; } }

        Note: Updated code.

Re: Error in CGI::Session on Windows: flock() not implemented
by InfiniteSilence (Curate) on Dec 12, 2005 at 19:13 UTC
    What Perl installation are you using on Windows (ActiveState...what version?) and can you run the following code (taken from the perldoc):
    use Fcntl ':flock'; # import LOCK_* constants sub lock { flock(MBOX,LOCK_EX); # and, in case someone appended # while we were waiting... seek(MBOX, 0, 2); } sub unlock { flock(MBOX,LOCK_UN); } open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}") or die "Can't open mailbox: $!"; lock(); print MBOX $msg,"\n\n"; unlock();

    Celebrate Intellectual Diversity

      I am using version 5.6.1

      code you gave doesn't work. It fails with message 'Can't open mailbox: no file or directory" because I am trying this in windows and it can't find '/usr/spool/mail...'

        Sorry, I suppose I should have told you to revise the file path to something that exists on your machine (probably c:\\temp\\something_or_other.txt). Revise and try and see if it dies on the flock() call. Update: Why aren't you using a newer version of Perl?

        Celebrate Intellectual Diversity