Perhaps I'm not understanding, but inserting undefs for missing values doesn't seem that bad. To ensure a value for each host/timestamp pair, you have two options:
- Use JOIN statement in your SQL to ensure you get a row for each timestamp regardless of other values
- Populate a HoH with your data, using the timestamp as the first key and each hostX as your subhash key.
The hash approach seems like it would be the most efficient to me, but that would depend on the amount of data, efficiency of the database, etc. If you did go that route, this is what your data structure would look like:
$VAR1 = '08:03';
$VAR2 = {
'host3' => 4,
'host2' => 4,
'host1' => 4
};
$VAR3 = '08:02';
$VAR4 = {
'host3' => undef,
'host2' => 3,
'host1' => 3
};
$VAR5 = '08:01';
$VAR6 = {
'host3' => undef,
'host2' => 2,
'host1' => 2
};
$VAR7 = '08:00';
$VAR8 = {
'host3' => 1,
'host2' => undef,
'host1' => 1
};
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.