Mahendra Thacker wrote:
> 
> 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";
> }


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



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to