[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Search::Dict?



On 2/11/1999 at 21:59, rjk@linguist.dartmouth.edu (Ronald J. Kimball) wrote:

> According to the documentation for Search::Dict (you did read the
> documentation, right?):
> 
Sure, as well as the Camel comments, but I didn't notice the * in *FILEHANDLE
originally. I also now notice that the docs describe the variables as I<$x> and
wonder what the leading I signifies?

>   Sets file position in FILEHANDLE to be first line greater than or equal
>   (stringwise) to $key.  Returns the new file position, or -1 if an error
>   occurs.
> 
> First, look() sets the *file position*.  In other words, it does a seek to
> the beginning of the line; this has nothing to do with $..
>
Okay, but doesn't this necessarily mean that the last line read has to be the
one that I'm after? Otherwise, how does it know what the position is?

> Second, if there is an error, look() returns -1, which is a *true* value.
> This is why your conditional succeeded even though the look() failed.  Test
> that the return value is >= to 0 instead.
If a negative result is true and that's what this returns on error then it will
be true no matter what if you just evaluate true/false? Good God. Originally, I
was testing for > -1 and then changed it to simple true/false in the course of
trying to get it to work. Thanks for the explanation.

Richard Gordon
Gordon Consulting & Design
Voice: 770-565-8267  Fax: 770-971-6887



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch