Re: search value in array

2008-08-28 Thread Rob Dixon
Irfan J Sayed (isayed) wrote: > Hi All, > > I want to search whether specific value/data is there are not in Array. > For example lets say i have array as follows. > > @test = (1,2,3,4,5); > $rel1=4; > > I need to check whether 4 is there or not. I have one method as follows. > > if (grep /

Re: search value in array

2008-08-28 Thread Raymond Wan
Hi Irfan, Irfan J Sayed (isayed) wrote: if (grep /^$rel1$/, @test) { print "Result = $rel1\n"; } but i think this is not the proper way because if i use grep then it would be a platform dependant. The grep you are using is not the grep provided by the operating system, but the