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

Re: [MacPerl] Re: Efficient Search in Perl?



At 14.49 1998.03.23, Shyam Hegde wrote:
>I have taken both yours and Michael Stoodts advice and resorted and
>rearranged my two text files.  Michael was right in assuming that I wanted
>to do a lookup for ID number on the first file and then use this ID to
>reference the second file.  I have reimplemented my program using the
>Search::Dict 'look' function and it runs much, much faster.  However the
>'look' function is innaccurate and doesn't seem able to make an exact match
>in over 50% of the times I have tried it (even when the word exists).  Is
>there any other function that performs the equivalent of an 'eq' for string
>match and '==' for integer match using the DB structure in Perl??  I want
>to be able to get 'supercomputer' on its own even if there is an entry
>before it like 'parallel_computer'.

Can you give a short example of the code you are using?  I don't seem to
follow what the problem is, exactly.

#!perl -wl
use Search::Dict;

$key = 'abandon';
open(FH1, ':b') || die $!;
look(*FH1, $key);
chomp($b = <FH1>);
print $b;

$key = '100002880';
open(FH2, ':c') || die $!;
look(*FH2, $key, 1);
chomp($c = <FH2>);
print $c;

This code works fine for me, and works every time.  It prints:

abandon,103826829
100002880,'(living things collectively; "the oceans are teeming with life")'

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



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