omit empty value statistics
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Sep 2019 18:28:17 +0000 (20:28 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 8 Sep 2019 13:57:09 +0000 (15:57 +0200)
barcat

diff --git a/barcat b/barcat
index 4c3cf8a763210ae3eb31fb7ecb41a25665da6ac0..600f453ffd3fad89a5ea764eada0338f745c7db4 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -181,11 +181,13 @@ if ($opt{stat}) {
                $opt{hidemax} ||= @lines;
                printf '%s of ', sum(@values[$opt{hidemin} - 1 .. $opt{hidemax} - 1]) // 0;
        }
                $opt{hidemax} ||= @lines;
                printf '%s of ', sum(@values[$opt{hidemin} - 1 .. $opt{hidemax} - 1]) // 0;
        }
-       my $total = sum @order;
-       printf '%s total', $total;
-       printf ' in %d values', scalar @values;
-       printf ' (%s min, %*.*f avg, %s max)',
-               $order[-1], 0, 2, $total / @order, $order[0];
+       if (@order) {
+               my $total = sum @order;
+               printf '%s total', $total;
+               printf ' in %d values', scalar @values;
+               printf ' (%s min, %*.*f avg, %s max)',
+                       $order[-1], 0, 2, $total / @order, $order[0];
+       }
        say '';
 }
 
        say '';
 }