Ken Cornetet wrote:
> That character would be a ^Z, which is an end-of-file indicator for
> microsoft. 
> 
> I can already hear people asking "Why the need for an EOF character when
> MS file systems record an exact byte count?" Ok, maybe it's just the
> usual voices in my head that I hear, but for at least their edification,
> I'll explain.
> 
> MSDOS was written to be as compatible as possible with THE business OS
> of the day: CP/M. In CP/M, file sizes were recorded by 128 byte (256
> bytes?) block count only - no byte count. Thus, text files needed an EOF
> character to show where the text ended.

That's why we have binmode in Perl.  All he had to do is add
        binmode INPUT;
after the open and no hang.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Vladimir Zelinski
> Sent: Tuesday, March 13, 2007 7:48 PM
> To: [email protected]
> Subject: Re: Hitting a line limit while reading a file 
> 
> A while ago I had a weird problem on Perl for Windows.
> My program exited from while(<INPUT>) loop because of a character in the
> data file which was treated as EOF.
> After removing the character from the data file loop continued up to the
> very end. I didn't have time to investigate the problem and I can't say
> what the character was. Try to look at data where your loop is
> terminated.
> 
> Thank you,
> Vladimir
> --- Sisyphus <[EMAIL PROTECTED]> wrote:
> 
> 
>>----- Original Message -----
>>From: "Howard Maher" <[EMAIL PROTECTED]>
>>To: <[email protected]>
>>Sent: Wednesday, March 14, 2007 5:34 AM
>>Subject: Hitting a line limit while reading a file
>>
>>
>>
>>>I was simply counting the number of lines in a 2
>>
>>gig file, printing to
>>
>>>STDERR every 10,000 lines to indicate the program
>>
>>was making progress, but
>>
>>>the program stopped at 12,960,000 lines read... an
>>
>>hour and a half later it
>>
>>>still hadn't budged...
>>>What kind of memory issue could I have hit?
>>>This is a Windows 2000 box with 512 Meg of RAM.
>>>
>>>Code that was executing:
>>>
>>>open(INPUT,"$infilename") or die "couldn't open
>>
>>$infilename for read,
>>
>>>stopped at: $!";
>>>my $line_num;
>>>while ( <INPUT> )
>>>{
>>>   $line_num++;
>>>   print STDERR "$line_num\r" unless
>>
>>$line_num%10000;
>>
>>>}
>>>
>>
>>There's no need to count the lines yourself. The special variable $. 
>>does that for you. (See 'perldoc perlvar):
>>
>>while(<INPUT>) {
>>   print STDERR "$.\r" unless $. % 10000; }
>>
>>I don't know what the problem is, and I think it's unlikely that 
>>change will fix things. But it's something you could try.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to