in reply to Re: Binary conditionals
in thread Binary conditionals

Just as an aside, you should also open the file in binmode. Generally only important on Windows, it is just good practice to specify it.

Replies are listed 'Best First'.
Re^3: Binary conditionals
by moritz (Cardinal) on Sep 30, 2008 at 15:26 UTC
    Is that needed even though :raw is used? I think that the binmode documentation isn't entirely clear. It says:
    If LAYER is omitted or specified as :raw the filehandle is made suitable for passing binary data.

    That reads as if it made a call to binmode superfluous, but on the other hand it talks about a certain orthogonality between IO layers and binmode HANDLE.

      That reads as if it made a call to binmode superfluous

      You're wrong. Without binmode the file handle is in text mode. With binmode but without specified layer, or with layer "raw", it is in binary (raw) mode. That's not the same thing at all, at least, on platforms other than Unix.

      A call to binmode is not superfluous. Instead, I think forgetting about it is the reason why the OP got corrupted data:

      I know I'm fubar'ing the handling somehow; just don't know how :P

      p.s. to the OP: hex('0x17') is a silly, slow way to do things, if you can just enter a hexadecimal numeric literal: 0x17.