Why would you want to use a global? Localizing the variable
prevents conflicts with an existing OUT file handle (if one exists),
makes sure the file handle gets closed as soon as the block/sub exits (whether it exited normally or via die),
makes sure the file handle gets flushed as soon as the block/sub exits (whether it exited normally or via die, since file handles are flushed when they are closed), and
makes sure the lock is realeased as soon as the block/sub exits (whether it exited normally or via die, since the lock is automatically realeased when the file handle is closed).
You should always limit the scope of your variables to where they are needed, using local or (even better) my.
{
# Make sure file gets closed and unlocked when we're done.
open(my $IN, '<', ...)
or die("...: $!\n");
# Wait for people to stop writting:
flock($IN, LOCK_SH)
or die("...: $!\n");
while (my $line = <$IN>) {
...
}
# close ($IN); # not really needed => closed at end of block
}