flock blocks until the lock is acquired.
That is, LOCK_EX doesn't return until all
current shared locks are released, and LOCK_SH doesn't
return until any exclusive lock is released.
Normally, you don't check to see if a file has been locked,
you simply ask for the lock and go about your business.
This is
all in the perlfunc manpage, though
the 5.6 docs are clearer...
Two potentially non-obvious but traditional flock
semantics are that it waits indefinitely until the
lock is granted, and that its locks merely
advisory. Such discretionary locks are more
flexible, but offer fewer guarantees. This means
that files locked with flock may be modified by
programs that do not also use flock.