disable markers without graph
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 4 Sep 2019 22:50:04 +0000 (00:50 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 5 Sep 2019 03:11:33 +0000 (05:11 +0200)
Avoid error "Modification of non-creatable array value attempted"
trying to access unallocated positions.

graph

diff --git a/graph b/graph
index b41f0c08855f1fbd73a17bedfb2ac1c5bfcfdedd..0d9db2e51c4aa110a11dabedb1219db7c3107f9b 100755 (executable)
--- a/graph
+++ b/graph
@@ -39,7 +39,7 @@ my $size   = ($maxval - $minval) &&
        ($opt{width} - $lenval - $len) / ($maxval - $minval);  # bar multiplication
 
 my @barmark;
-if ($opt{markers} // 1) {
+if ($opt{markers} // 1 and $size > 0) {
        sub orderpos { (($order[$_[0]] + $order[$_[0] + .5]) / 2 - $minval) * $size }
        $barmark[ (sum(@order) / @order - $minval) * $size ] = '=';  # average
        $barmark[ orderpos($#order / 2) ] = '+';  # mean