# line processing program my ($file,$start,$stop) = @ARGV; $start ||= 0; $stop ||= -s $file; open my $fh, '<', $file; seek $fh, $start, 0; # now position at the first line after $start # if we're not starting at the beginning of a file if ($start) { <$fh>; }; my $position = tell $fh; while (<$fh> and $position <= $end) { $position += length $_; ... };