From: Nicolas Boisselier Date: Sun, 11 Jun 2023 20:28:03 +0000 (+0200) Subject: no extra space for last field when option format X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e8a2ea99189f10fb2abfb2c7073b74e5b4ef1a3f;p=nb.git no extra space for last field when option format --- diff --git a/bin/csv2human b/bin/csv2human index c4203843..3784ffd3 100755 --- a/bin/csv2human +++ b/bin/csv2human @@ -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;