Gossamer Forum
Home : General : Perl Programming :

Fcntl vs flock (default variables)

Quote Reply
Fcntl vs flock (default variables)
I am using flock in the script but would like to use 'Fcntl' variables, just want to confirm two things.

1. Can I replace flock(FH, 2); safely with flock(FH, LOCK_EX); without making any other changes.

Or should I also Add.....

use
Fcntl qw(:DEFAULT :flock);

in my script?

Thanks for input.

Zeshan.
Quote Reply
Re: [zeshan] Fcntl vs flock (default variables) In reply to
Hi,

If all you need from Fcntl is the flock constants, then you should use:

use Fcntl qw/:flock/;

and then yes, you can replace flock(FH,2) with flock(FH, LOCK_EX).

Cheers,

Alex
--
Gossamer Threads Inc.