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:
printf "%-10", $elementToPrint;
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)
#Max Column length in parenthesis.
(9) (14) (7) (8) (3) (7) (8)
OWNER | 999?SheetMusic |ralph |50054441 |156 |pts/220 |9:00:44
WAITING-0 | 999?SheetMusic |randall |33096504 |35 |none |9:10:44
WAITING-1 | 999?SheetMusic |kelly |55555556 |999 |pts/900 |9:00:00
OWNER | 001!SCHEDULE |joe |51515154 |000 |tty/100 |10:00:00
WAITING-0 | 001!SCHEDULE |mvick |12345677 |886 |none |9:20:00
WAITING-1 | 001!SCHEDULE |russel |76543215 |456 |tty/101 |10:00:00
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.
Thanks Again,
Matt
.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.