Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^7: Perl Hashes, keys under keys (I think)?

by mmartin (Monk)
on Sep 22, 2011 at 15:02 UTC ( #927386=note: print w/ replies, xml ) Need Help??


in reply to Re^6: Perl Hashes, keys under keys (I think)?
in thread Perl Hashes, keys under keys (I think)?


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


.


Comment on Re^7: Perl Hashes, keys under keys (I think)?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-09-22 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls