X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/3f7e3fb002626412e76a781ba93d12f72562afcc..9fad4d7ae54232c20df3ea2d874c2483aaca6c3c:/barcat diff --git a/barcat b/barcat index c5b7e0a..9cfe3e3 100755 --- a/barcat +++ b/barcat @@ -35,7 +35,7 @@ GetOptions(\%opt, 'hidemax=i', 'minval=f', 'maxval=f', - 'limit|L=s' => sub { + 'limit|L:s' => sub { my ($optname, $optval) = @_; $optval ||= 0; ($opt{hidemin}, $opt{hidemax}) = @@ -236,9 +236,13 @@ while ($nr <= $#lines) { $nr >= $opt{hidemax} and last if defined $opt{hidemax}; my $val = $values[$nr]; my $rel = length $val && ($val - $minval) / ($maxval - $minval); + my $color = !length $val || !$opt{palette} ? undef : + $val == $order[0] ? $opt{palette}->[-1] : # max + $val == $order[-1] ? $opt{palette}->[0] : # min + $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ]; if ($opt{spark}) { - print $opt{spark}->[ + print color($color), $opt{spark}->[ !$val ? 0 : # blank $val == $order[0] ? -1 : # max $val == $order[-1] ? 1 : # min @@ -249,10 +253,6 @@ while ($nr <= $#lines) { } if (length $val) { - my $color = !$opt{palette} ? undef : - $val == $order[0] ? $opt{palette}->[-1] : # max - $val == $order[-1] ? $opt{palette}->[0] : # min - $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ]; $val = $opt{units} ? sival($val) : sprintf "%*s", $lenval, $val; color($color) for $val; } @@ -367,7 +367,7 @@ unless C<--length=0>. Prepend a dash (i.e. make negative) to enforce padding regardless of encountered contents. -=item -L, --limit=(|-[]) +=item -L, --limit[=( | -[])] Stop output after a number of lines. All input is still counted and analyzed for statistics,