Hello jhuijsing,
I think you missed this from the documentation:
$trie->lookup(word, suffix_length)
This method performs lookups on the trie. In list context, it returns a complete list of words in the trie which begin with word. In scalar context, the value returned depends on the setting of the 'deepsearch' option.
So, the deepsearch option has effect only in scalar context:
use strict; use warnings; use Tree::Trie; my $trie = Tree::Trie->new( { deepsearch => 'prefix' } ); $trie->add_data ( '+61' => 'Term', '+611411' => 'Outleg_1', '+6114110' => 'Outleg_2', '+65' => 'Term_Ref', default => 'unknown', ); my $result = $trie->lookup('+612'); print "+612: $result\n";
Output:
17:18 >perl 1830_SoPW.pl +612: +61 17:18 >
But when you assign the result of lookup() to an array, you put the function call into list context, and the deepsearch option does not apply.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: A question about Tree::Trie
by Athanasius
in thread A question a Tree::Trie
by jhuijsing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |