Thanks! You are exactly right about why my scalar wasn't working; I was calling it as 'my ($var).' Can you give me a quick line on why I should/shouldn't have the parenthesis on that?
I seem to have the multi-data working now, and I'll show you what I did. I suspect it is pretty sloppy, un-idiomatic code, so any suggestions for a cleaner implementation are welcome. Here we are. First, my CSV format (for reference):
"PrimaryTest","normalSentiment","negSentiment","topics" "a waste",-1,0,""
Now my code:
while (my $fields = $csv->getline( $data )) { my $word = $fields -> [0]; my $pos_sent = $fields->[1]; my $neg_sent = $fields->[2]; my $topics = $fields->[3]; my @word_info = ($pos_sent, $neg_sent, $topics); # Trying with a reference my $pnt_word_info = \@word_info; $trie->add_data($word => $pnt_word_info); my $info = $trie->lookup_data($word); printf "Just added %s\n Sentiment: %s \t Neg Sentiment: %s \t Topi +c: %s\n", $word, $info->[0], $info->[1], $info->[2]; }
In reply to Re^2: Scalar data & collection data with Tree::Trie
by Endless
in thread Scalar data & collection data with Tree::Trie
by Endless
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |