How to match string inside of array?



If I have an array like:

@arr = ('one', 'two', 'three');

And the varaible $myvar = 'two';


How do I check if $myvar matches 'two' in @arr?

I know I could iterate through the array with
a foreach statement, but was wondering if there
was a more efficient method.

-Thanks


.



Relevant Pages

  • Re: How to match string inside of array?
    ... > How do I check if $myvar matches 'two' in @arr? ... > I know I could iterate through the array with ... > a foreach statement, ...
    (comp.lang.perl)
  • Re: non repeating random numbers
    ... numeric array, all of its elements are set to zero. ... However, as I said in the beginning, this method of assigning ... (making it an efficient method to use). ...
    (microsoft.public.vb.general.discussion)
  • Re: How to match string inside of array?
    ... >> I know I could iterate through the array with ... >> a foreach statement, ... Posted Via Usenet.com Premium Usenet Newsgroup Services ...
    (comp.lang.perl)
  • Re: How to match string inside of array?
    ... >> I know I could iterate through the array with ... >> a foreach statement, ... mybox:> perldoc -q contains ...
    (comp.lang.perl)
  • Re: Object Serialisation
    ... If the contents of an array can be repesented as text then you could use ... objects are stored in a master object / collection. ... start...or is there a more efficient method? ...
    (microsoft.public.excel.programming)