http://www.perlmonks.org?node_id=240833


in reply to File Locking Tricks and Traps

Cool. I've often used flock to ensure only one instance of a program is running, but I never thought of opening $0 and locking that - consequently each of my scripts litters the filesystem with a matching .lck file.