diff --git a/filter.pl b/filter.pl index cb43a5c..9003965 100755 --- a/filter.pl +++ b/filter.pl @@ -89,16 +89,41 @@ foreach my $item (keys %seen) { @uniq = sort { GA->comp($a, $b) } @uniq; -# my @uniq = sort gw_comp keys %seen; -if (@uniq) { - if ($newlines) { - foreach my $item (@uniq) { - print $item->str, "\n"; +if ($newlines) { + if ($ranges) { + while (my $item = shift @uniq) { + my $from = $item; + my $to = $item; + + my @copy = @uniq; + foreach my $next (@copy) { + if ($next->{top} == $to->{top} and $next->{middle} == $to->{middle}) { + if ($next->{bottom} == ($to->{bottom} + 1)) { + $to = $next; + shift @uniq; + } + } + } + + if ($from != $to) { + print "$from->{top}/$from->{middle}/[$from->{bottom}-$to->{bottom}]\n"; + } else { + print $from->str, "\n"; + } } } else { foreach my $item (@uniq) { - print $item->str, " "; + print $item->str, "\n"; } + } +} else { + if ($ranges) { + print "ranges not implemented for non-nl output\n"; + } + foreach my $item (@uniq) { + print $item->str, " "; + } + if (@uniq) { print "\n"; } }