in reply to Using fcntl function for the first time

Precedence issues. Try replacing those '||'s with 'or's. For example, this
my $flags=fcntl $fh,F_GETFL,0 || die "fcntl call failed: $!\n";
is being seen by the compiler as:
my $flags=fcntl $fh,F_GETFL, (0||die "fcntl call failed: $!\n");

Dave.