my $fh = undef; ( -e "access.lock" || open( $fh, ">", "access.lock" )); if ( not defined( $fh )) { # report that someone else is editing the file } else { # write client/session-id data to access.lock and close it # so you can verify when this client sends the update }