in reply to I've got an enormous...file
If I understood correctly you are looking for a way of reading a file in chunks of 10 lines. Probably you can use cpan modules for that (Tie::File or DB_File). But this is another way (using an iterator):
use strict; use warnings; sub getNlines { my ($fh,$nLines) = @_; return sub { my $linesRead = 0; my $rec; $rec .= <$fh> for (1..$nLines); return $rec; } } open my $ff, "<", shift @ARGV or die $!; my $get10lines = getNlines($ff,10); ## will retrieve 10 lines per cal +l while (my $rec = $get10lines->()){ ## Process next 10 lines print "$rec\n"; }
Hope that this helps
citromatik
|
|---|