Howard Maher wrote: > 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; > }
This code takes 5 secs on my AMD 64 3200+. There should be no way this would hang and memory shouldn't be an issue since you're only reading a line at a time unless you have some sort of real system problem. You could add a binmode IN just to avoid any newline issues and see if it makes a difference. use strict; use warnings; my $infilename = 'E:/tmp/registry-03-19-05.txt'; # ASCII registry dump open IN, $infilename or die "open $infilename: $! ($^E)"; # binmode IN; # try this also my $pt0 = Win32::GetTickCount (); # start timer my $lines; while (<IN>) { ++$lines; print STDERR "$lines\r" unless $lines % 10000; } close IN; printf STDERR "\nFound %u lines in %.3f seconds\n", $lines, (Win32::GetTickCount () - $pt0) / 1000; __END__ Output: Found 1025713 lines in 5.250 seconds _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs