- if (defined $opt{min} or $opt{max}) {
- state $seen;
- my $count = $seen->{ $_->[0] }->{ $_->[1] // '' }++;
- next if $count >= ($opt{min} // 0) + ($opt{max} || 1);
- next if $count < ($opt{min} // 0);
+ my $line = $_->[2] // join(': ', @$_);
+ $line =~ s/^/$hash / if defined $hash;
+
+ if (defined $opt{min} or $opt{max} or $opt{count}) {
+ my $counter = \$headercount{ $_->[0] }->{ $_->[1] // '' };
+ my $excess = $$counter++ - ($opt{min} // 0);
+ next if $excess >= ($opt{max} || 1);
+ next if $excess < 0;
+ if ($opt{count}) {
+ push @headercache, [ $line, $excess ? \undef : $counter ];
+ next;
+ }