If I understand the description, you want a boolean value for each date+state tuple -- that is: "there (was | was not) at least one tornado on date X in state Y".

If that is the case, think about creating an array of 50 elements (one for each state). The value of each element is a reference to a hash, where the keys of the hash are the dates when one or more tornados occurred in the given state (the value assigned to each element is of no importance: it is the existence of a given date as a hash key for the given state that matters). So, suppose the data is like this:

State Date other stuff 1 03/03/2003 one bad mother of a storm... 5 03/05/2003 nothing to write home about... 8 02/08/2003 they said it could never happen here ...
You might try something like this, just to list how many tornado days there were in each state, based on the given input report:
my @states; # array holding one hash per state while (<>) { my ($state_number,$date) = split; $states[$state_number]{$date} = undef; } # now to summarize: # for each state that had any tornados at all, # list number of tornado days: for ( 1 .. 50 ) { if ( defined $states[$_] ) { printf( "state_id %2d: %3d tornado days\n", $_, scalar keys %{$states[$_]} ); } }
(untested, of course)

In reply to Re: Help with calculating stats from a flat-file database by graff
in thread Help with calculating stats from a flat-file database by nadocane

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.