On Sat, 2 Jan 1999 18:02:11 -0500, Chris Nandor wrote: >flock() does not work with MacPerl. One method that can work is with a >separate lock file: create a file called "file.lock" and have your other >programs fail while "file.lock" exists. That approach is flawed in some >ways (if your program dies, then everything is locked out until you fix it >manually or something), but it is an alternative. Then try opening the file for output. Unlike Unix, but like PC, the Mac only allows opening for writing only to one program at a time. If your script dies, the file is automatically closed. Problem solved. open(LOCK,'>file.lock') or die "File locked ($!)"; If you want to be the only one to read/write to a particular file at a time, open iot for both reading and writing, e.g. using '+<', and truncate() if necessary. This is very similar to the way you HAVE to open a file for output in Applescript: MacPerl: open(FILE,'+<whatever') or die "Can't open file: $!"; truncate(FILE,0); AppleScript: open for access file "whatever" with write permission set fhandle to result set eof fhandle to 0 Actually, in MacPerl, you're better off using: open(FILE,'+<whatever') or open(FILE,'+>whatever') or die "Can't open file: $!"; because otherwise it would fail if the file didn't exist before. Then again, maybe that's just what you want. Of course, you could repeat trying to open the file until it succeeds, preferably with some pause between the tries. I'm not sure what good it is. After all, you can only run one MacPerl script at a time. Or do you plan to simultaniously open this file using another program as well? Bart. ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch