in reply to Re: Re: News script again
in thread News script again

The name flock is a contraction of "file lock". The syntax for it is available via perldoc -f flock, or here.

Why? Because if two programs, or two instances of the same program (as you may get from a web server) attempt to rewrite the same file at the same time you lose changes.

For example:

Worse:

Now half the file is simply missing!

By calling flock() before starting to read the file, the problem will be avoided, as prog 2 will simply stall until prog 1 releases the lock.