return ($count, $lines);
}
- $start = 0 if !$start;
- $limit = 50 if !$limit;
+ $start = $start // 0;
+ $limit = $limit // 50;
+ my $read_until_end = ($limit == 0) ? 1 : 0;
my $line;
if ($filter) {
while (defined($line = <$fh>)) {
next if $line !~ m/$filter/;
next if $count++ < $start;
- next if $limit <= 0;
+ if (!$read_until_end) {
+ next if $limit <= 0;
+ $limit--;
+ }
chomp $line;
push @$lines, { n => $count, t => $line};
- $limit--;
}
} else {
while (defined($line = <$fh>)) {
next if $count++ < $start;
- next if $limit <= 0;
+ if (!$read_until_end) {
+ next if $limit <= 0;
+ $limit--;
+ }
chomp $line;
push @$lines, { n => $count, t => $line};
- $limit--;
}
}