GetOptions(\my %opt,
'debug!',
'simplify|s:s',
- 'unique|u!',
'ignore-case|i!',
+ 'min|min-count|unique|u:i',
+ 'max|max-count|show|n:i',
) or die;
local $| = 1;
next LINE;
};
+ push @header, $_ if defined $opt{max};
+
given ($opt{simplify} // 'no') {
when ('strict') {
$header[1] =~ s{
}
when (['text', '']) {
when ($header[0] =~ /[ _-] (?: by | to ) $/imsx) {
- pop @header;
+ $header[1] = undef;
}
for ($header[1]) {
s{\b (https?)://\S+ }{[$1]}gmsx; # url
}
}
when (['all', 'any']) {
- pop @header;
+ $header[1] = undef;
}
when ('no') {
}
}
if ($opt{'ignore-case'}) {
- $_ = lc for @header;
+ $_ = lc for $header[0], $header[1] // ();
}
+ pop @header if not defined $header[-1];
+
push @headers, \@header;
}
}
for (@headers) {
- if ($opt{unique}) {
+ if (defined $opt{min} or $opt{max}) {
state $seen;
- next if $seen->{ $_->[0] }->{ $_->[1] // '' }++;
+ my $count = $seen->{ $_->[0] }->{ $_->[1] // '' }++;
+ next if $count >= ($opt{min} // 0) + ($opt{max} || 1);
+ next if $count < ($opt{min} // 0);
}
- say join ': ', @$_;
+ say $_->[2] // join(': ', @$_);
}
last BLOCK;