----- Original Message -----
From: bclark1 <[EMAIL PROTECTED]>
Date: Thursday, July 14, 2005 6:48 am
Subject: flock and open files

> Hi list
Hello,
> 
> My colleaque and I have just had a small disagreement with each 
> other 
> about file locking and reading / ammending a txt file.
> 
> To up date a CSV file (it must be quick and / or effient), my 
> colleaquelikes to either read the whole file in memory (I dont 
> like this) or
> open the file and use seek etc.
> 
> I like to open the file, open a tem, use a while, print the line 
> to the 
> temp file, and on the line im looking for do what I need then 
> print to 
> the temp file and then close the file and then unlink the original 
> and 
> then rename the file.
This is just a choise of preferance, as long as you can be certain that no 
other processes are modifying the file while you are at it, techniqe makes no 
differance [ surly one will be faster and more secure then other ].

> 
> The other one is file locking. My colleaque says the flocking does 
> not 
> work on Linux, where as I say the flock works for both Linux as 
> well as 
> win32. I read the perldocs and I have not seen anything proving 
> him 
> right, but as the same time I have not seen anything that proves 
> him wrong.
reading perldoc -f flock...

" Calls flock(2), or an emulation of it, on FILEHANDLE. Returns
 true for success, false on failure. Produces a fatal error if
 used on a machine that doesn't implement flock(2), fcntl(2)
 locking, or lockf(3). "flock" is Perl's portable file locking
 interface, although it locks only entire files, not records."

Sounds like any OS that supports these system calls, will work. Surely most [ I 
have never herd of one] linux systems will support these system calls. you 
should also know that <C>flock will not actualy lock the file, just set locking 
bit on.
 
> So if anyone share their experiences or tips is would be most 
> appreciated.
> Please bare with me on this, still new to perl / programming.
> 
> Kind Regards
> Brent Clark
Cheers,
mark G.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to