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

This:
my $data = <<EOF; first second EOF
evidently deletes the <CR> characters.

Hmm, I'm quite surprised by that, and I'm still looking for the place where that's documented. Even trying to turn off the default :crlf layer on Windows doesn't seem to restore the CRLFs in $data. In addition, even on *NIX, eval "<<BAR\r\nx\r\ny\r\nBAR" causes the returned value to have only \n's, so it appears to be something to do with how heredocs are parsed. In fact, I've reported a bug.

Replies are listed 'Best First'.
Re^9: Error binmode() on unopened filehandle
by Marshall (Canon) on May 07, 2020 at 04:05 UTC
    I've been away for awhile and I am answering posts in LIFO order.
    At the end of the day, I do not recommend using a here-doc like shown to generate a binary byte sequence. There are other ways that "for sure" will work.

    Of course a binary file doesn't always have printable ASCII characters.