in reply to Re: Appending data to locked file
in thread Appending data to locked file

Here is the code : $logFile = "C:\\WORK\\a.log"; open(LOGFILE, ">>$logFile") || die "$! $?"; print LOGFILE ("HELLO \n"); close(LOGFILE); output : Permission denied 0 at a.pl line 3. the file "a.log" is kept open with swriter. I can see a file named ".~lock.a.log#" at same location where a.log exists. The $? comes out to be 0 and $! is permission denied. I use Active perl 5.8.8. Platform windows.

Replies are listed 'Best First'.
Re^3: Appending data to locked file
by cdarke (Prior) on Jan 08, 2010 at 08:57 UTC
    Thanks for the update.
    I could only generate a lock file if the file is created by swriter - if the text file already exists it does not generate a lock file (no idea why). However, that still did not generate your symptoms.
    I can exactly reproduce your problem by making the file read-only. Could it be that this is nothing to do with locking but simply that you do not have write/append permissions?

    By the way, $? has nothing to do with this issue. That is the exit status of the previous child process and, so far as I can tell, you are not running any.