in reply to File locking with semaphores

I managed to spot another error with the above code. The unlock function should be:
sub unlock{ my $self=shift; my $FH=*{$$self{SEMAPHORE}}; if(-e $SEM){ flock($FH,LOCK_UN); close $FH; unlink $SEM; } }
That cleared up some errors that I was getting. And what jasonk suggested cleared up the ambiguous opens. I am still getting the following errors:
Use of uninitialized value in ref-to-glob cast at /opt/perl5/lib/site_ +perl/5.6.0 /Logger/Simple.pm line 85. Use of uninitialized value in ref-to-glob cast at /opt/perl5/lib/site_ +perl/5.6.0 /Logger/Simple.pm line 98.

TStanley
--------
It is God's job to forgive Osama Bin Laden. It is our job to arrange the meeting -- General Norman Schwartzkopf

Replies are listed 'Best First'.
Re: Re: File locking with semaphores
by runrig (Abbot) on Mar 07, 2003 at 20:26 UTC
    I still don't get why you are dereferencing the FileHandle object. It works just fine as is (maybe depends on perl version?). I don't understand what goes on when you dereference the FileHandle object, but this code seems to demonstrate that you get a different GLOB every time, which I would think is not what you want:
    use strict; use warnings; use FileHandle; my $fh = new FileHandle; my $FH1 = *{$$fh}; my $fh1 = \$FH1; my $FH2 = *{$$fh}; my $fh2 = \$FH2; print "$fh1\n"; print "$fh2\n"; ############ output: GLOB(0x20043704) GLOB(0x200436f8)