in reply to Flock and Subroutine

Have you read this: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example) ?

Some of these same issues are discussed there.