Subject: | _format_line() converts zeros to nulls |
The sprintf statement in _format_line() uses a || operator to determine whether to output the value contained in $col_lines[$i][$h] or ''. I'm assuming the intent here was to catch null or undefined values. However, this will catch any "false" value, including the number zero (0) as well as the zero string "0". As a result, any field that consists of the number zero or the zero string will be replaced with null ''.
The following patch will correct this:
@@ -263,8 +263,8 @@
for my $h (0 .. $height - 1 ) {
my @line;
for (my $i = 0; $i <= $#$columns; $i++) {
- push @line,
- sprintf " %-" . $lengths->[$i] . "s ", $col_lines[$i][$h] || '';
+ my $val = defined($col_lines[$i][$h]) ? $col_lines[$i][$h] : '';
+ push @line, sprintf " %-" . $lengths->[$i] . "s ", $val;
}
push @lines, join '|', "", @line, "";
}
Cheers