On 4/14/05, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
> 
> 
> John W. Krahn wrote:
> >
> > perldoc -f binmode
> >      binmode FILEHANDLE, LAYER
> >                          ^^^^^
> 
> ...
> 
> >              If LAYER is present it is a single string, but may contain
> >              multiple directives. The directives alter the behaviour of the
> >                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >              file handle.  When LAYER is present using binmode on text file
> >              ^^^^^^^^^^^
> 
> ...
> 
> > Also see:
> >
> > perldoc PerlIO
> 
> Thanks John :)
> 
> So if I'm reading right:
> 
> binmode $fh; # binary mode
> binmode $fh, :crlf; # ascii mode ??
> 
> Would effectively undo binmode $fh; correct? or am I missing the right
> LAYER?
> 

You're confusing layers with encodings.  Layers deal with (primarily)
types of data; encodings deal with specifications.  Text is a type of
data; ascii is a type of text (or a type of binary, depending on
whether you see it as a string of octets or a sting of bytes or a
string of bits).  And most encodings don't really care what layer
you're using, except in very weird situations.  The whole point of
layers is to may IO transparent.  In most situations Perl is smart
enough to figure it out for you, especially when you're dealing with
text.  You can usually write out text to file to binmoded file,
especially if your sure your text is all 7-bit ascii, which you must
be, because you're asking about ascii.  what you can't do is
effectively write much binary data to file opened :crlf or :utf8. 
This is why File::Temp has the defaults it does: 99% of perl programs
deal with text, and yet, File::Temp opens files with :raw.  Why? 
Because that should work for most people most of the time.

Take a close look at 

perldoc PerlIO
perldoc PerlIO::encoding
perldoc Encode

Also keep in mind that :crlf != ascii.  ASCII is a spec for encoding a
certain set of characters into bytecode.  :crlf deals with how one
particular byte sequence is interpreted when sent to and received from
the OS/FS.  The only thing is changes about your data is the bytes
written out fo \n.

But once again, there's no code here.  What have you treid with
File::Temp?  What errors have you received, or what unexpected results
have you had with it?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to