]> git.nbdom.net Git - nb.git/commitdiff
no extra space for last field when option format
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 11 Jun 2023 20:28:03 +0000 (22:28 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 11 Jun 2023 20:28:03 +0000 (22:28 +0200)
bin/csv2human

index c42038436e9cc7eac2f778d3cd157e330828dd08..3784ffd31719fc01ab2e3f4dc657caf843a2bf1e 100755 (executable)
@@ -76,9 +76,18 @@ my $t = -1;
 my $format = "| ".join(" | ",map {$t+=$_+3; "\%-".$_."s"} @len)." |".chr(10);
 my $sep_line = "+".join("+",map {("-"x($_+2))} @len)."+".chr(10);
 
+# a => 1
+# b => 222222
 if ($Opt{format}) {
        my $sep = " ".$Opt{sep}." ";
-       $format = join($sep,map {$t+=$_+length($sep); "\%-".$_."s"} @len).chr(10);
+       my $i;
+       $format = join($sep,map
+       {
+               $i++;
+               $t+=$_+length($sep);
+               $i == @len ? '%s' : "\%-".$_."s";
+       }
+       @len).chr(10);
        $sep_line = "";
        $VERBOSE = 0;
        $Opt{total} = 0;