usr/bin/perl
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 );
$trie->lookup("+61");
$trie->lookup("+612");
| [reply] [d/l] |
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,
| [reply] [d/l] [select] |
Thanks
The perils of coding when you don't read all the documentation and try to use something new
| [reply] |