develooper Front page | perl.beginners | Postings from March 2002

searching an array

Thread Next
From:
Mahendra Thacker
Date:
March 29, 2002 16:09
Subject:
searching an array
Message ID:
20020330000911.52316.qmail@onion.perl.org
Hi,

A question from a relative newbie.

How does one search an array of numbers for a number?
(without using foreach; is there any function?)

Say, I want to do something like this:

==

$a = 5;
@arr = ( 7 9 3 6 );

if ( seach( $a, @arr ) ) {
   print "Found $a in the list \n";
} else {
   print "Did not find $a in the list\n";
}

==

TIA,

Mahendra Thacker




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About