This code is my attempt to create a more robust locking mechanism. Is there anyway I can get the filename from the filehandle? I could pass it in as a parameter, but I'd rather pass as few parameters as possible.sub sleep_lock { my $FH = *{$_[0]}; my $lock_type = $_[1]; my $time = $_[2] ||5; for ( 1..$time ) { last if flock $FH, $lock_type; unless ( $_ < $time ) { die "Can't lock file: $!" }; sleep 1; } }
Are there any other problems anyone sees?
In reply to Filename from filehandle? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |