in reply to Re: flock and open
in thread flock and open

Why would you want to use a global? Localizing the variable

You should always limit the scope of your variables to where they are needed, using local or (even better) my.

Replies are listed 'Best First'.
Re^3: flock and open
by strat (Canon) on Feb 09, 2006 at 09:22 UTC

    Well, then why not using lexical filehandles? e.g

    { # 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 }

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"