title: In Perl, how can I check if a file is locked?
body: <p>How exactly would I check to see if a file is locked exclusively? I have this function but it is returning 1 no matter what I do: </p>
  
  <pre><code>sub is_file_locked
  {
    my $theFile;
    my $theRC;
  
    ($theFile) = @_;
    $theRC = open(HANDLE, $theFile);
    $theRC = flock(HANDLE, LOCK_EX|LOCK_NB);
    close(HANDLE);
    return !$theRC;
  }
  </code></pre>