in reply to Re: flock on on $^I
in thread flock on on $^I
The problem is that it's not recognising "lockit" or "unlock" when the filelock subroutine is called. Even though when I print out @_ it displays "lockit" or "unlock" accordingly. What am I doing wrong ?sub filelock; filelock "lockit"; Do the inplace edit stuff here filelock "unlock"; sub filelock { if ( @_ eq "lockit" ) { open(LCK,">abc.lock") or die "Can't open abc.lock: $! \n"; unless (flock LCK, LOCK_EX) { warn "Waiting to obtain lock on LCK ....\n"; flock(LCK, LOCK_EX) or die "Cannot lock semaphore file + - $!\n"; } } if ( @_ eq "unlock" ) { close(LCK) } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: flock on on $^I
by Anonymous Monk on Aug 19, 2010 at 14:37 UTC |