http://qs321.pair.com?node_id=216699


in reply to flock error...?

"Get a REAL OS," so goes the chant of the rabble.

Problem is this. If you've got multiple processes with a file open for writing and reading at the same time, trouble results. So you need locking. The flock() call is one method of locking a resource in Perl.

In Win98/95, only one user is expected to be using the system at a time. Thus, file locking (at least on this level) shouldn't really be a concern, right?. The OS won't allow more than one process in Win98/95 to have a file open for writing at the same time. That solves the locking problem and makes flock() unnecessary for the OS... The problem is that Perl wants to use this locking mechanism, but it simply doesn't exist in Win98/95.

So what do you do? Well, if this were a long-term thing I'd agree with the rabble. If you're just working out the bugs, noodling around with the system before it goes into production, try this:

# Change this flock(FH, LOCK_EX) || die "Error in flock: $!"; # Into this (untested, no Win98 machine handy) eval { flock(FH, LOCK_EX) || die "Error in flock: $!"; }; die unless ($@ =~ /unimplemented/);
This will essentially ignore the flock()'s on Win95/98, but they really shouldn't be a concern of yours anyway if you're just testing, right?