I know this is more of an algorithm question but please bear with me.


In my program I am checking wether a emailid exists in a list I have in the complete_list a string like $complete_string="<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> ... <[EMAIL PROTECTED]>";

# that is a string of emailids sorted

Now I want to find out if another ID "<[EMAIL PROTECTED]>" exists in this list

How is it possible to optimize the search given that the complete list string is sorted in order

The alternative I am considering is
1) Create a hash array with each of the ids as keys and just use the exits function


like
my %hash=();
while($complete_list=~/(\<.*?\>)/g){ $hash{$1}=1 };
....
if(exists($hash{$emailid})) {
        # FOUND id in string
}

Is this the best way

Is there no way directly to use the string
Thanks
Ram


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to