On Sun, Sep 30, 2007 at 05:35:00PM -0400, Jim wrote:> foreach my $match ( @matches ) {
> my %hit;
> my %ht;
> my $doc = $match->get_document();
> my $per = $match->get_percent();
> my $id = $match->get_docid();
> my $bterm = $enq->get_matching_terms_begin($id);
> for(my $xit=$bterm;$xit !=
> $enq->get_matching_terms_end($id);$xit++) {
> my $term=$xit;
> print $term;
> }
>
> Which doesn't really make any sense. Xit is a string and I don't
see
> how incrementing a string will do anything useful. So how do you
> increment the iterator?
Actually, $xit is an object, but overloads "" so when you print it you
get a string. Just use "++" to increment, like you are already doing
(though the preincrement may be more efficient - i.e. ++$xit). Or
you can use "inc".
> This does return the terms until it hits the end case then it hangs,
> perl just keeps clocking time. I have to kill it.
Not sure what's going on here. You used to have to use "ne" not
"!=" to
compare iterators but we added overloads for "!=" ages ago as it was
too
easy to get wrong.
Can you post a complete script to demonstrate this hang?
> If I run the following, the same thing happens:
> my %eterm = $enq->get_matching_terms_end($id);
That's assigning an iterator object to a hash - what do you expect it to
do?
Cheers,
Olly