So I added the following block to count up the instances of each category

my %categories = (); while ( my $name = <$dataIn1>) { chomp($name); my ($file, $category) = split(/\t/, $name); if (exists($categories{$category})) { $categories{$category} += 1; } else { $categories{$category} = 1; } } foreach my $category (sort { $categories{$b} <=> $categories{$a} } key +s %categories) { printf "%s: %s\n", $category, $categories{$category}; }

My variable naming is terrible because I picked that up from stack overflow and adjusted it to fit. But my question then becomes how do I pluck data from this data structure, and the %subres structure? Most of my limited playing has been with arrays, so I'm struggling when it comes to this.

I know this isn't anywhere near correct, but could this be considered heading in the right direction?

something like: my $score = $subres->[2] Foreach $category in $categories {where %subres [0] = $category} ($sco +re = ($subres [1] / ($categories{$category}))

If you can see through the non-existent formatting, my intent is to match each category from the categories list to it's corresponding category in the attribute results list, and then divide the result value by the category count value, and push that answer into the list.


In reply to Re^9: Best way to store/access large dataset? by Speed_Freak
in thread Best way to store/access large dataset? by Speed_Freak

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.