[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding item in simple array
However, I cannot access either of the links mentioned below - i get the
message :
"The page you're looking for
is no longer available."
Any alternative suggestions ?
Geoff Evans.
At 19:48 08/12/2000, you wrote:
On Fri, 8 Dec 2000, Miriam Blake
wrote:
> Is there an easy way just to test for the existence of something in
a
> simple array (not a hash)?
>
> I have $item and I want to see if it exists in @array and I don't
want
> to do a foreach over @array every time...
Miriam-
Scratch that last message of mine, where I suggested something that
I
perhaps should not have suggested.
One of the best ways of doing what you ask is to use not arrays,
but
hashes. Or, if changing to a hash is impractical, check out some of
the
creative uses of shadow hashes at the following location:
<URI:http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#How_can_I_tell_whether_a_list_or>
Alternately, jump to
<URI:http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html> and
look
for the question "How can I tell whether a list or array contains
a
certain element?".
-jeff
--
Jeff Godin
Network Specialist
Traverse Area District Library / Traverse Community Network
jeff@tcnet.org
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered
through the MessageLabs Virus Control Centre. For further information
visit
http://www.star.net.uk/stats.asp
_________________________________________________________
Geoff Evans
Technical Consultant
Talis Information Ltd.
Birmingham Research Park
Vincent Drive
Birmingham Phone : +44 (0)121 471 1179
B15 2SQ Fax : +44 (0)121 472 0298
United Kingdom E-Mail: G.B.Evans@talis.com
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
_____________________________________________________________________
Any views or personal opinions expressed within this email may not be those of Talis Information Ltd.
The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.