tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ Arguments to tie()

[Q]: flocking file from read to write? ▻

Problems with PERL and Locking?

In article <4ftgoi$tu@ptang.bevc.blacksburg.va.us>,
Dave Sisson <daves@bev.net> wrote:
>open(TMP, "tmpfile") || die "Could not open tmpfile!\n";
>[...]
>  fd = open("tmpfile", O_RDWR);

Spot the difference?  You're trying to obtain an exclusive lock,
and to do that you need a filehandle which is open for writing.

Try something like this.

    open TMP, "+< tmpfile" or die "open: $!\n";

Tim.
--
Tim Goodwin   | "I just noticed that a SUN SLC takes longer to
UUnet PIPEX   | get to its boot prompt than it takes to build
Cambridge, UK | its [ Plan 9 ] kernel." -- Phil Winterbottom

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: Problems with PERL and Locking?
Date: 15 Feb 1996 17:25:40 GMT
Organization: Unipalm PIPEX
Message-ID: <4fvqak$ccc@wave.news.pipex.net>
References: <4ftgoi$tu@ptang.bevc.blacksburg.va.us>

△ comp.lang.perl △

◅ Arguments to tie()

[Q]: flocking file from read to write? ▻