ashok13123 has asked for the wisdom of the Perl Monks concerning the following question:
The first if statement will print the value is not present and the next will print Value is present....Why???How can i rectify it?????????@arr1=qw(a b c d e sdf); $val1="http://www.google.com/home?sFocus=(sFocus.value)&sLis +t=(sList.value)"; push(@arr1,$val1); $val="sdf"; if(grep(/$val1/i,@arr1)) { print "Value is present\n" ; } else { print "Value is not present\n"; } if(grep(/$val/i,@arr1)) { print "Value is present\n" ; } else { print "Value is not present\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search for array element
by ikegami (Patriarch) on Jun 18, 2009 at 15:01 UTC | |
|
Re: Search for array element
by kennethk (Abbot) on Jun 18, 2009 at 14:56 UTC |