in reply to in function?

If it's a one-time test, using grep as suggested by plaid is the quickest way to go. If you are going to perform many tests, setting up a hash as suggested by ferrency will speed things up a lot in the long run.

If you go the hash way, there is another, shorter way of initializing the array using a hash slice:

@myhash{@myarray}=(1) x scalar(@myarray);
Note that @myhash is being used, although %myhash is the one being initialized.

--ZZamboni