|Perl Monk, Perl Meditation|
Re^7: Perl Hashes, keys under keys (I think)?by mmartin (Monk)
|on Sep 22, 2011 at 15:02 UTC||Need Help??|
hbm, thanks for the reply.
Nice I like that one you suggested: @colLens = map length, @header; cool stuff!
I had did what you suggested about the print statements inside each looping area, but I had removed them when I copy/pasted it over to the post, just to make it a little easier to read. And what I noticed was that the first 2 loops where giving the correct lengths but everything after that was not.
Basically, the end result I want is that I will print a table of the records, which will have as many rows as there are records and 8 columns wide.
And in order to get a nice, readable table printout I'd use this:
I'm sure you know that this will make a "cell" in the table 10 spaces wide and left justified.
And what I did in another program I wrote was replace "10" with $colLens[$x], where $x is the largest length of the string in each element for every record, including the @header elements as well.
So for an example, if I have the following data: (I removed a couple of the column elements so it fits on the page correctly)
The end result should be that @colLens = (9, 14, 7, 8, 3, 7, 8)
Sorry if I confused you more, trying my best to explain it as well as I can haha.
Let me know if you think of anything.