On Thu, Jul 05, 2001 at 10:43:48AM +0100, Leon Brocard wrote:
> David Cantrell sent the following bits through the ether:
> 
> > I have frequently wanted to overload operators when not using objects -
> > for example, I wanted to overload == to tell me whether a list contained
> > a certain scalar
> 
> % perldoc -q contains
>        How can I tell whether a list or array contains a certain
>        element?
> 
>        Hearing the word "in" is an indication that you probably
>        should have used a hash, not a list or array, to store
>        your data.  Hashes are designed to answer this question
>        quickly and efficiently.  Arrays aren't.

There are multiple occurences of the same value in the dataset, so I can't use a hash.
I could do the usual trick of temporarily converting it to a hash and then seeing if
the scalar is a key, but that is just fugly.

-- 
David Cantrell | [EMAIL PROTECTED] | http://www.cantrell.org.uk/david

             If a job's worth doing, it's worth dieing for

Reply via email to