For socket introduction, see
http://perldoc.perl.org/perlipc.html...-Communication
As for checking whether the file is being held open, I think you can't get this information. You can just assume that when, e.g. copy or move returns, that file has been moved. But you know the OS may return before this is physically completed and give you a view that the file has been relocated, but the writing is still going on (due to DMA, maybe). flocks won't work either because of its discretionary nature.
The typical way is to write some dummy, hidden file to indicate the status beforehand, just as vim does. The file is cleaned when the operation completes. That's why shell scripts are usually full of this kind of tricks.