Edward WIJAYA wrote:
On Wed, 17 Nov 2004 16:35:58 +0530, Prasanna Kothari <[EMAIL PROTECTED]> wrote:
try using grep function. perldoc -f grep
Yes correct, didn't think of that before.
@exist_elems = grep {/$mystring/} @array_orgn;
0) there is no 'my' in that example, use strict and warnings :) (my @exists_elems ...)
1) what if $mystring is foo and the array elements are foobar, food,bazfoo - it will be true but it doesn't contain your string really ?
2) what is the variable contains malicious code?
This addresses all of those things:
print 'Yes it exixts' if grep /^\Q$mystring\E$/, @myarray;
HTH :)
Lee.M - JupiterHost.Net
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
