in reply to Re^5: Perl Hashes, keys under keys (I think)?
in thread Perl Hashes, keys under keys (I think)?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Perl Hashes, keys under keys (I think)?
by mmartin (Monk) on Sep 22, 2011 at 15:02 UTC | |
|
Re^7: Perl Hashes, keys under keys (I think)?
by mmartin (Monk) on Sep 22, 2011 at 16:11 UTC |