in reply to Re^2: seek() functionality on pipes
in thread seek() functionality on pipes

Yes. Also, depending upon the OPs reqs, it might be better to use sysread rather than read. Most file format specs are in terms of bytes not chars.

I'm never quite sure whether Perl will start treating input as unicode without a specific request on an open to do so? For example, does it recognise BOMs in an input stream and act upon them?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: seek() functionality on pipes
by ikegami (Patriarch) on Jul 21, 2008 at 19:34 UTC

    I'm never quite sure whether Perl will start treating input as unicode without a specific request on an open to do so?

    None of the default PerlIO layers do any conversions except :crlf.

    However, there could be action at a distance (such as from an open pragma).

    That's why binmode should be used on file handles containing binary data (such as the OP's compressed file). It avoids any such problem.

    For example, does it recognise BOMs in an input stream and act upon them?

    :encoding(UTF-16) uses the BOM to determine byte ordering, but something needs to tell open to use :encoding(UTF-16) first.

        Or $ENV{PERLIO}.