Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)by scorpio17 (Canon) |
on Dec 03, 2009 at 22:07 UTC ( [id://810965]=note: print w/replies, xml ) | Need Help?? |
Thanks for the feedback, everyone. Here's my revised version:
Here's an example of something using it:
A few notes: ikegami: I don't understand this line from your code:
This tests for an error condition, after getting a lock, and if you're running on Windows... 33?! It seems to work okay without this check, but I'd like to understand this better, for future reference. Also - it seems like the file handle ($fh) needs to be a global variable, so I used 'our' instead of 'my'. If I use 'my', then when the package goes out of scope, the lock gets dropped! mortiz: I'd like to add something like this: To turn on the print statement. Something like this:
... but I don't see how to accomplish this using only an export tag. Any hints? I'm not planning to upload this to CPAN. It seems too simple to bother. Besides, merlyn solved this problem over 9 years ago! He should get the credit, not me. Thanks again for the helpful comments, everyone.
In Section
Meditations
|
|