in reply to Re: binmode for @ARGV
in thread binmode for @ARGV

For those of you smug about always being on Unix, it is now recommended to use binmode even on Unix to avoid unwanted Unicode semantics.
  1. Mac OS is sane too so you should address smug users from both camps.

  2. Saying "it is recommended" doesn't mean much without the source of the recommendation.

    Though the ability to set layers for filehandles has been grafted onto binmode(), they can also be set via the open pragma and overridden with the three argument form of open(). If I were making my own recommendation, I'd suggest these over binmode() as being clearer and more natural.

  3. You're oversimplifying.

    IO layers are, to be fair, a separate issue from that which started this discussion. The use of layers is a powerful abstraction which provides a lot of functionality over and above the ability to fix braindead line terminations and EOF markers.

    Furthermore, for the most part, perl tries pretty hard to do the Right Thing™ (on sane platforms) regardless of whether layers are specified. Backward compatibility is, as always, a high priority so the default behavior is for perl to behave as it always has. My understanding is that the exception occurs when one has specified their preference for Unicode semantics via one of the locale environment variables, in which case, presumably, you know what you are doing.

To the best of my knowledge, using binmode on binary files is recommended regardless of platform but only for portability reasons. In my case, most of what I write is specific to unix anyway because it supports systems that are themselves tightly coupled to unix. Usually, my only portability concern is that my code will build and run unaltered on Irix, Solaris, various BSDs, and Linux. Unsurprisingly, I regularly ignore binmode() as being wholly superfluous and I'll continue to do so until I hear a good reason not to.

-sauoq
"My two cents aren't worth a dime.";