my @colLength; sub calcMaxColumn { # $i will hold index locations of column lengths in the array @colLengths. my $i; # Loop through the array @AoA. And if the length of the current column is greater then the length of the # same column in the previous row then set the greater number equal to that location in @colLength. for (my $x = 0; $x <= $#AoA; $x++) { $i = 0; for (my $y = 0; $y <= 11; $y++) { if ($colLengths[$i] < length($AoA[$x][$y])) { $colLengths[$i] = length($AoA[$x][$y]); } $i++; } } } #### my $strLen = 0; for (my $x = 0; $x <= $#AoA; $x++) { #If the current line is an owner then there will only be 10 elements. if ($AoA[$x][0] eq 'OWNER') { $waitline = 10; } #ELSE the line is a user waiting and we should add the time waiting to the end of that line, 11 total elements. else { $waitline = 11; } for (my $y = 0; $y <= $waitline; $y++) { $strLen = $colLengths[$y]; printf OUTDATA "%-${strLen}s ", $AoA[$x][$y]; } print OUTDATA "\n"; }