From e8a2ea99189f10fb2abfb2c7073b74e5b4ef1a3f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 11 Jun 2023 22:28:03 +0200 Subject: [PATCH] no extra space for last field when option format --- bin/csv2human | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; -- 2.47.3