you can use map function, too :)

<code>
$a = 5;
@arr = qw( 7 9 3 6 );

%search = map { $_ => 1 } @arr;

if ( $search{$a} ) {
   print "Found $a in the list \n";
} else {
   print "Did not find $a in the list\n";
}
</code>

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";
> }
> 
> ==
> 
> TIA,
> 
> Mahendra Thacker
> 
> 
> 
> 



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

Reply via email to