Hi nop!

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:

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' } } }
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:
# 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 } }
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 :) .

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.