0

Possible Duplicate:
How do I lock a file in Perl?

Does anyone know how to lock a text file in Perl so only one thing can write to it until it is unlocked? I need something other than setting the read/write attributes. Thanks.

Community
  • 1
  • 1
Christopher Peterson
  • 983
  • 7
  • 22
  • 32

1 Answers1

2

Take a look at flock.

Hugmeir
  • 1,249
  • 6
  • 9
  • 3
    Keep in mind that this is only an *advisory* lock - there is nothing actually stopping another program from going ahead and writing to the file anyway. – Anon. Dec 20 '10 at 21:02
  • The links[1], they are everywhere[2] : )! Edit: Didn't work as expected. Oh well. [1]: http://stackoverflow.com/questions/34920/how-do-i-lock-a-file-in-perl [2]: http://perldoc.perl.org/perlfaq5.html#How-can-I-lock-a-file? – Hugmeir Dec 20 '10 at 21:05