develooper Front page | perl.perl5.porters | Postings from April 2003

A bunch of I/O layer questions

Thread Next
From:
Nathan Torkington
Date:
April 10, 2003 08:23
Subject:
A bunch of I/O layer questions
Message ID:
16021.35953.683554.427050@Nathan-Torkingtons-Computer.local.
I'm batching these for your and my sanity.  Some are not phrased as
questions.  The implicit question is "is this right?  If not, what
am I missing?"

Terminology help: There are two kinds of layers: those that change the
implementation, and those that translate the data en route to or from
the implementation.

(1) binmode() pushes translation layers onto the stack rather than
clearing the stack and beginning again.

(2) Because the :pop interface is experimental, I should recommend
that people always give a "full path" of layers if they want to
change the translation layers.  That is, always start with ":raw".

(3) Is the open pragma the only way to change the layer set with which
ARGV processed files are opened?

(4) There's no way from Perl to get the layer stack string (or array)
for a particular filehandle.

(5) There's no way to find out what your default layer set currently
is.

(6) There are no real world situations where you'd want to set :crlf
except "I'm on a Unix system and I'm reading a Windows file and I want
Perl to automatically translate the line endings for me".  This is
unportable because it assumes you know the operating system.  You
don't need to set :crlf when you normally read a text file, because if
you're on a system that needs newline conversion then it's already in
the default layer stack.

(7) Corollary to (6): If you change the default layer stack to :raw
with the open pragma, you can never portably read a text file again
because you can't know whether you're supposed to have :crlf or not.

Thanks,

Nat


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About