in reply to Re: permission denied error when reading thru set of text files at once!!!
in thread permission denied error when reading thru set of text files at once!!!

You can't LOCK_EX a file opened only for input, only for output.

$ perl -E' use Fcntl qw( LOCK_EX ); open(my $fh, "<", ".bashrc") or die; flock($fh, LOCK_EX) or die; say "ok"; ' ok

Can't? no. But does it make sense to? Probably never.

  • Comment on Re^2: permission denied error when reading thru set of text files at once!!!
  • Download Code

Replies are listed 'Best First'.
Re^3: permission denied error when reading thru set of text files at once!!! (flock)
by tye (Sage) on Mar 15, 2011 at 13:28 UTC

    flock is implemented several different ways in different builds of Perl. Some of those ways indeed do not even allow exclusive locks against read-only file handles.

    - tye