if($opsys eq "unix"){flock(FILE, 2);}
else{binmode(FILE);}
This is a curious construct; the logic appears to be "lock the filehandle on systems described by the identifier 'unix', set binmode on the filehandle on other systems".
If you think you might need binmode, set it anyway; it's a no-op on systems that don't make the distinction. And try not to mix operations like that within an if {...} else {...}. Future maintenance programmers will not thank you for it.
Final point; don't use 'magic' numbers, as you do in flock() here, particularly if there's some likelyhood of cross-platform use. Use the constants provided by the Fcntl module instead.
use Fcnlt qw(:flock);
open(FILE, "+<$bookfile")
|| &debug("Oops, I cannot read the bookfile $bookfile: $!");
if($opsys eq "unix"){flock(FILE, LOCK_EX) # Error-check here.}
else { # What do we do on other systems? }
binmode FILE;
|