I think I agree with brother t0mas, use a module like PDL. Barring that, it seems that this sort of datacube is not very complex (for one you specify that you are required to specify all the arguements must be present unless specifically doing a reduction op).
If this is truely the case I suggest just a nested hash. Why not? Just:
With that you can just reference an item with: $dc->{'north-america'}{'01/01/99'}{'gross'}{'web'} If you want a reduction, you can pass the $dc reference to a procedure along with a list of fields such as:my $dc = { 'north-america' => { '01/01/99' => { 'gross' => { 'we +b' => 99.99 'counter' => 10.95 } 'misc' => { 'web' => 2.50 } } { '01/02/99' => { 'gross' => '93.23' } } }
Sorry I'm chickening out writing that -- I just realized I'm late -- I have to drive to Montgomery. I'll rely on my brethren to fill in the blanks :) .# supporting constants: my %fnum = { 'region' => 0, 'date' => 1, 'type' => 2, 'channel' => 3 } +; my $fsize = 4; sub reduce { my ($dc,$f) = @_; # sort fields to keep in decending order my @keep = reverse sort map { $fnum{$_} } @$f; for $cnt ($fsize-1 .. 0) { # hard code goes here! lol } }
One last thing, this is very easily bordering on "hairy" as a procedural program, I would suggest implementing the hash of hash's as an object so that you can get rid of these constants and make the whole thing more flexible and transparent. Good luck!
Cheers,
Gryn
In reply to Data cube == hofhofhof.. ?
by gryng
in thread Data cube in Perl?
by nop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |