omit abbreviation mark on --trim=1
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 4 Sep 2019 21:55:58 +0000 (23:55 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 5 Sep 2019 03:11:33 +0000 (05:11 +0200)
The first character should be whitespace or another delimiter to be kept.
Contents can be assumed cut and does not need an indicator.

graph

diff --git a/graph b/graph
index 781af217dc8e0da33769f4ed35ce527b8242eb61..a764afdcffc2b54c86f11411827eaa55d9d7e7f4 100755 (executable)
--- a/graph
+++ b/graph
@@ -26,7 +26,8 @@ my @values = map { s/^\h* ( -? [0-9]* (?:\.[0-9]+)? )//x and $1 } @lines;
 my @order  = sort { $b <=> $a } grep { length } @values;
 if ($opt{trim}) {
        my $trimpos = abs $opt{trim};
-       length > $trimpos and substr($_, $trimpos - 1) = '…' for @lines;
+       $trimpos == 1 ? ($_ = substr($_, 0, 1)) :
+       (length > $trimpos and substr($_, $trimpos - 1) = '…') for @lines;
 }
 
 my $maxval = $order[0];