perl arrays

Hi

I need some help using arrays in perl.
I have an array say var and a variable var1.
I want to check if the var1 is present in the array. How do I check that ?

my @var = 1...10;
my $var1 =5;

if ( $var1 in @var )
{
.......
}
else
{
.......
}

Something like above. Can some look give me the exact code
Thanks in advance
ammu

if ( grep (/$var/, @var1) ) {
}

Inefficient way but OK for a small list:

my @var = (1..10);
my $var1 = 5;

if ( grep {$_ == 5} @var ){
   print "found it\n";
}
else {
   print "did not find it\n";
}

More efficient if you have a large list to search through:

my @var = (1..100000);
my $var1 = 9999;
my $flag = 1;
for ( @var ){
   if ($_ == $var1) {
      print "found it\n";
      $flag = 0; 
      last;
   }
}
if ($flag) {
   print "did not find it\n";
}

Large probably means thousands/millions of elements in the array. For an array of a few hundred elements or less using grep is OK.