That depends on what you're using @mylist for.  If you're simply using it to
check to see if an element is in the list, then use a hash instead.

If you're creating the list element - b
        push @mylist, $whatever;
you can say
        $myhash{$whatever}=1;

Then your search-loop collapses into
        if ($myhash{'AF00001'}) {...}

If, for some reason, you need the information in a list and not a hash, then
use a grep instead of the for loop:
        if (grep /^AF00001$/, @mylist) {...}

HTH!  ;)

-----Original Message-----
From: Jennifer Pan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 26, 2001 1:55 PM
To: [EMAIL PROTECTED]
Subject: if in a list


I want to test if "AF00001" is in my list @mylist;

I did: 

foreach $LIST (@mylist) {
        if ($LIST = "AF00001") 
                $boolean = 1;
        else 
                $boolean = 0;
}

is there a more elegant way to do it?

many thanks

jennifer

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

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

Reply via email to