Perldoc is your friend:
perldoc -f flock # Gives you the documentation for Perl's flock
perldoc -q lock # Gives you FAQ information about the ins and outs of file locking in Perl.
Perl provides "advisory" locking, so a process is free to ignore the lock. But since the OP was interested in protecting a script from itself, this works OK and keeps the Perl script as pure as it can be.
Erik