My/Array.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 22 CC 1 SCAR 6.9
CC
1
Cov
0%
max_lengths
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package My::Array;
2  
3 use v5.32;
4 use Mojo::Base -strict;
5 use List::Util qw( max );
6  
7 =head2 max_lengths
8  
9 Returns an array of the lengths of
10 the longest strings per array.
11  
12 Nice for making evenly spaced out tables.
13  
14 =cut
15  
16 sub max_lengths {
17 my ( $s, $rows ) = @_;
18 my $last_row = $rows->$#*;
19 my $last_column = $rows->[0]->$#*;
20  
21 my @max = map {
22 my $col = $_;
23 max map { length $rows->[$_][$col]; } 0 .. $last_row;
24 } 0 .. $last_column;
25  
26 \@max;
27 }
28  
29 1;