I don't quite understand what you are doing here, but generally you ought to avoid nested loops. I suspect this for-for-for can be achieved earlier, when you are first building %records.
But as you have it, confirm what is happening with temporary print statements before each of your assignments:
if (int($colLens[$x]) < length($rec1)) { printf "colLens:%s, rec1:%s\n", $colLens[$x], $rec1; $colLens[$x] = length($rec1); ...
Also, stylistically, instead of:
for (my $y = 0; $y <= $#header; $y++) { $colLens[$y] = length($header[$y]); }
Consider:
@colLens = map length, @header;
I look forward to your final, working program!
Update: I also meant to say, you have int(length(...)) in a few places. length returns an integer, so no need to wrap it with int.
In reply to Re^6: Perl Hashes, keys under keys (I think)?
by hbm
in thread Perl Hashes, keys under keys (I think)?
by mmartin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |