SimpleBackuper/_print_table.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 4 SCAR 26.4
CC
4
Cov
0%
_print_table
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 package App::SimpleBackuper;
2  
3 use strict;
4 use warnings;
5  
6 sub _print_table {
7 my($table, $header_rows_cnt) = @_;
8
9 my @column_lengths = (0) x @{ $table->[0] };
10 foreach my $row ( @$table ) {
11 $column_lengths[ $_ ] = length $row->[ $_ ] foreach grep { ! $column_lengths[ $_ ] or $column_lengths[ $_ ] < length $row->[ $_ ] } 0 .. $#$row;
12 }
13
14 for my $q ( 0 .. $#$table ) {
15 if($header_rows_cnt and $header_rows_cnt == $q) {
16 print '-' x ($column_lengths[ $_ ] + ($_ ? length(' | ') : 0)) foreach 0 .. $#{ $table->[$q] };
17 print "\n";
18 }
19 for my $w ( 0 .. $#{ $table->[ $q ] } ) {
20 printf "%-$column_lengths[ $w ]s", $table->[ $q ]->[ $w ];
21 print $w == $#{ $table->[ $q ] } ? "\n" : ' | ';
22 }
23 }
24 }
25  
26 1;