Perl::Critic is probably wrong on this one... or at least, insensitive to valid use cases. That's a frequent issue with Perl::Critic; while the book was intended to encourage thoughtfulness with respect to best practices, the module doesn't do a very good job of trying to understand why your situation might justify using an item that it considers to be a violation. The best practice really is to know what you're doing, and why. The rest is just food for thought.
By the way, you may find this slide interesting: MJD "Only one process running at a time", from Mark Jason Dominus's File Locking Tricks and Traps talk.
Update: I almost forgot to mention -- this employs the "lock the DATA filehandle" trick, and allows you to avoid dealing directly with flocking: Sys::RunAlone.
|