----- Original Message ----- 
From: "Howard Maher" <[EMAIL PROTECTED]>
To: <perl-win32-users@listserv.ActiveState.com>
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.

Cheers,
Rob



_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to