in reply to Re^8: Best way to store/access large dataset?
in thread Best way to store/access large dataset?
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.
|
|---|