Here is one shot: #!perl -w
my $a = 5; my @arr = qw( 7 9 3 6 5); my @MyHits = grep(/$a/ , @arr ); if ( @MyHits ) { print "Found $a in the list \n"; } else { print "Did not find $a in the list\n"; } Made minor changes: used warnings, my. Wags ;) -----Original Message----- From: Mahendra Thacker [mailto:[EMAIL PROTECTED]] Sent: Friday, March 29, 2002 16:09 To: [EMAIL PROTECTED] Subject: searching an array 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]