No such thing as a small change | |
PerlMonks |
Re^5: Computing results through Arraysby aaron_baugher (Curate) |
on Jun 05, 2015 at 18:44 UTC ( [id://1129235]=note: print w/replies, xml ) | Need Help?? |
You're getting close! The main problem is with your loop logic. You want to print a header line starting with "connectionTime," followed by the database names. You can do that with something like this:
Now you want to start going through the actual data, printing it so that it lines up with the headers. So this loop follows the previous one, instead of being inside it:
I haven't tested that, but it's just a bit of an adjustment to what you had. Once it works, the next thing you'll probably want to look at is replacing the print statements with printf, which will help you line things up in columns even though the values are of different lengths. One more thought: for efficiency's sake, we should probably sort the %db hash keys once and put them in an array, rather than re-sorting them every time we print a line. But it'll work this way, so we can deal with that next time. Aaron B.
In Section
Seekers of Perl Wisdom
|
|