in reply to Re^4: Error binmode() on unopened filehandle
in thread Error binmode() on unopened filehandle

Ok. But I refer you to https://perldoc.perl.org/functions/binmode.html.
In general, binmode should be called after open but before any I/O is done on the filehandle.
Yes, there are some exceptions to this "rule". But I figure this "rule" is a good one.
  • Comment on Re^5: Error binmode() on unopened filehandle