in reply to reading 100 line at a one time
in thread reading 100 line at a one time
Whenever you want to repeat something a given number of times, use a loop. For example, in this case the function to read n lines from a filehandle could be:
sub read_n_lines { my ($fh, $count) = @_; my $buffer; $buffer .= $_ for 1 .. $count; return $buffer; }
Use it something like:
open(my $handle, 'c:/file.log') or die "Can't read file: $!\n"; while(not eof( $handle )) { my $chunk = read_n_lines( $handle, 100 ); my $parsed = parse_chunk( $chunk ); print_parsed( $parsed ); }
You might need a little more logic in read_n_lines() to check for eof, but if you look at the documentation and play around a little bit, you'll figure it out.
|
|---|