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

Re: [MacPerl] Some suggestions?



on 5/19/99 7:42 AM, Allan Greenier wrote...
>Greetings fellow users of the sublime MacPerl,
>
>I'm making a CGI search engine. Any suggestions as far as fastest way to
>search and optimization are appreciated.
>
>The engine will search a list that looks like this:
>("Data<TAB>Data<TAB>Data<TAB>Data","Data<TAB>Data<TAB>Data<TAB>Data").
>This list will be 500 items long. Sometimes it needs to search in the
>first item, sometimes the others. Usually only one item.
>So i do:
>
>foreach $item (@thelist){
>@itemarray = split (/\t/,$item)
>if $itemarray[0] eq $searchitem{
>dosomething } 
>}

while would be faster that foreach, after all I presume that you will 
need to read the file anyway.

while (<DATA>)
{
@itemarray = split (/\t/, $_);
   if ($itemarray[0] eq $searchitem) { do something... }
}


>I'm concerned that I could search 2000 (4x500) items before I get to one
>I want. After I find that one, I will need to extract $itemarray[3]
>everytime.

>So how do I construct this in the quickest way possible??
>Thanks pals,
>Allan Greenier
>AutoScript Applications
>
>agreenier@snet.net
>http://www.geocities.com/~autoscript

2000 records should not present a problem as far as speed unless your 
$item is very large.


Scott

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org