From: Raymond Wan <rwan.w...@gmail.com>
> On Fri, May 8, 2009 at 8:58 PM, John W. Krahn <jwkr...@shaw.ca> wrote:
> 
> >
> > That depends on the operating system you are using.  I use Linux so there
> > is no difference between "binary" and "text", except for those specific
> > applications that can't handle "binary" data.  If you are on a system like
> > DOS/Windows then reading or writing "binary" data as "text" will cause
> > problems because line ending translation occurs with "text" files but not
> > with "binary" files.
> 
> I'm on a Linux system too; I guess I've used it for so long, I  forgot about
> the situations when binary/text does matter (i.e., Windows).  I see...so it
> doesn't matter.  That would make  sense since I just pipe to stdout right
> now and whether I'm sending "text" [ie.,  human-readable characters] or not,
> it  all seems to work fine...

Well ... it seems, but it doesn't have to. Based on the locale 
settings, if you do not binmode() the filehandle or open it with the 
right IO layer specified, the stuff you print may undergo some 
charset conversions.

perldoc -f binmode says

On some systems (in general, DOS and Windows-based systems) binmode() 
is necessary when you're not working with a text file. For the sake 
of portability it is a good idea to always use it when appropriate, 
and to never use it when it isn't appropriate. Also, people can set 
their I/O to be by default UTF-8 encoded Unicode, not bytes.

In other words: regardless of platform, use binmode() on binary data, 
like for example images.


Jenda
===== je...@krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to