http://qs1969.pair.com?node_id=130398


in reply to Re: How to find out if X is an element in an array?
in thread How to find out if X is an element in an array?

This may be simplistic, but what about the following code. Anyone?

# # Given: first value passed is the element to check for # Given: remaining values are the array to check in # sub find_in_list { my ($element, @list2check) = @_; return(scalar(grep($element, @updatelist))); }

Replies are listed 'Best First'.
Re: Re: Answer: How to find out if X is an element in an array?
by juliansnail (Initiate) on Apr 07, 2004 at 00:08 UTC
    Do this or if you search for "1" it'll find "1" as well as "123"...
    return(scalar(grep(/^$element$/, @updatelist)));
    -julian geek