[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: Macperl file locking (was:Re: [MacPerl] IO:: problems)



At 15.32 9/18/97, David Turley wrote:
>Could Chris or somebody please explain exactly what the Macperl
>equivilent to flock() is?

#!perl -wl015
use Mac::Files;
my $file = 'test1';

&testOpen;
FSpSetFLock($file);  #lock file
&testOpen;
FSpRstFLock($file);  #unlock file
&testOpen;

open(F,$file);
while (<F>) {chomp;print}
close(F);

sub testOpen {
    my $x = open(F,">>$file");
    print F 'hi' if $x;
    close(F);
    if ($x) {print 'Success!'}
    else    {print 'Failure!'}
}

__END__

Returns:
Success!
Failure!
Success!
hi
hi


--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch