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
};