Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Perl
Expertise: Intermediate
Jun 21, 2004

Write to a Perl File Using Flock

In his tip "Locking a File With the Perl Flock Function," Steve Renaker's example opens a file without specifying read or write. While this will successfully open a file for reading, the context of this example (indeed the very reason for using flock in the first place) involves writing to a file:

open (FILE, ">data.txt");
flock (FILE, 2);
Now, the file is available for writing. In the original example, the file was indeed locked so no other script could write to it, but the example code would not be able to write to it either.

Jaime Bellmyer
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap