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

Re: Finding item in simple array

Geoff Evans <gbe@TALIS.COM> --

Geoff> However, I cannot access either of the links mentioned below - i get the
> message :
> "The page you're looking for is no longer available."

Looks like perl.com is getting out of mirroring perlfaq.

> Any alternative suggestions ?



works for me.

Finding items efficiently in arrays breaks into several cases:

1. Lotsa lookup, large array.
Use hashes. Tie them to disk with DBM if necessary.
Consider using the standard Perl interface to relational
DBs if the finding gets complex. LDAP might be a good

2. Small array, rare lookup. Just iterate through the

3. Intermediate. Remember which items you put in
the array in some data structure more suited to
your lookup pattern. (Like a hash, or a stack of
recent entries, etc). You can make this look like
a hash lookup with fancy tieing. I s'pose you can
make this look like an array iteration with tieing,
but that seems unperlish to me.

If we know more about your situation we may be able
to think of something more specific.
> Geoff Evans.

--Derek Lane

Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.