Subject: | binmode is always turned on |
$binmode is defined to a code ref. So this will always return true, because as a scalar, $binmode will be set to something like:
CODE(0x811f318)
The fix is to replace this line:
binmode( $fh ) if $binmode;
With this:
binmode( $fh ) if $binmode->();
That will force the $binmode subroutine to actually be called and return a value.