in reply to Trying to select the best data structure
One question: does the order of the pair ($word1, $word2) matter? In other words (making the same assumption as to what you mean as bobf above), is:
I will notequivalent to:
will I notfor your purposes, or is it different?
Update: Since you say "I think I will be accessing these parings via the $word1-$word2 parings", why not use an HoH, with $word1 and $word2 stringified as the key to the outer hash, and populate it something like this:
# foreach group of three words $hash{$word1 . ' ' . $word2}{$word3}++;
Or, more generally, for any number of words in your 'chain':
# foreach group of n words in array @n_words my $nth_word = pop @n_words; $hash{join ' ', @n_words}{$nth_word}++;
And if the answer to my question in the first part of this post is that order doesn't matter, just change that last line to:
$hash{join ' ', sort @n_words}{$nth_word}++;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to select the best data structure
by chinamox (Scribe) on Oct 29, 2006 at 13:25 UTC |