[comp.lang.perl] Question about Perl on DOS and EOF problem.

kevin@jarthur.claremont.edu (Kevin Fink) (02/28/91)

I am using Perl to convert some files from one format to another. The files
contain hex 1A codes (EOF markers), which need to be read as data, just like
any other code. However, as soon as the first of these comes by, I get an
eof and everything I try to getc after that comes up null.

How do I get around this? The code looks something like:

open(IN,"DATAFILE");
for($i=0;$i<100;$i++)
{
 getc(IN);
 .do.something.with.it...
}

Thanks.

Kevin Fink

lbr@holos0.uucp (Len Reed) (03/03/91)

In article <11006@jarthur.Claremont.EDU> kevin@jarthur.claremont.edu (Kevin Fink) writes:
>I am using Perl to convert some files from one format to another. The files
>contain hex 1A codes (EOF markers)....
>How do I get around this? The code looks something like:
>
>open(IN,"DATAFILE");

At this point say
binmode(IN);

which will put the stream into binary mode.  The default is text mode,
which translates CR/LF to LF and stops at the stupid-descended-from-the-
days-of-CPM-for-God's-sake end of file character.
-- 
Len Reed
Holos Software, Inc.
Voice: (404) 496-1358
UUCP: ...!gatech!holos0!lbr