Jabir Ahmed wrote:
> Hello everyone,

Hello,

> I have a pretty simple problem
> 
> example : 
> 
> @a=qw( 1 2 3 4 5 6 7 );
> $b=5;
> 
> now i just want to check if the value of $b i.e 5
> exists in the array @a or not
> 
> Q 1) is there any way other than looping through the
> array?

To do it without looping you could store the elements as hash keys, or if the
elements are sorted you could use a binary search.

> Q2 ) is there any predefined function to check the
> existance of the element in the array..

http://search.cpan.org/~vparseval/List-MoreUtils-0.12/



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to