Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
BEGIN {
use Fcntl qw(LOCK_EX LOCK_NB);
open SELF, '<', $0 or die "Failed to open $0: $!";
flock SELF, LOCK_EX | LOCK_NB or exit;
}
i got a warning from perlcritic about bare filehandles so i converted it to a lexical variable, but then the flock stopped working. not sure why this doesn't work, because the pod for flock shows an example with a lexical variable:
BEGIN {
use Fcntl qw(LOCK_EX LOCK_NB);
open my $self, '<', $0 or die "Failed to open $0: $!";
flock $self, LOCK_EX | LOCK_NB or exit;
}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to convert lexical filehand so flock will work with it
by davido (Cardinal) on Jul 05, 2013 at 07:09 UTC | |
by Anonymous Monk on Jul 05, 2013 at 07:30 UTC | |
by davido (Cardinal) on Jul 05, 2013 at 07:42 UTC | |
|
Re: how to convert lexical filehand so flock will work with it
by kcott (Archbishop) on Jul 05, 2013 at 06:52 UTC |