zarlag has asked for the wisdom of the Perl Monks concerning the following question:
ok so i want to ask for a input and after the user inputs a word the program than goes threw every index in the array of words. if the word is not in the array than print word is not in array. if it is in array than print it is in array. im working on a program that requires this algorithm/protocol but i seem to have a problem matching a input with a initialized value in a array. improvement in code or help with this problem of my would be nice i been struggling with it for about a week and cant seem to find how to make it work. how would i macth a string that is in array. thanks for the help in advanced.my $word; my @wrds; my $w; my $tries=0; while($tries!=2){ print "enter a word:"; $word=<STDIN>; chop $word; while($word != @wrds[$w]){ $w++; if($word = @wrds[$w]){print "found MACTH!!";} } $tries++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: macthing a word a in array of words
by Marshall (Canon) on Apr 02, 2011 at 15:54 UTC | |
by zarlag (Initiate) on Apr 03, 2011 at 13:57 UTC | |
by Marshall (Canon) on Apr 03, 2011 at 23:22 UTC | |
|
Re: macthing a word a in array of words
by wind (Priest) on Apr 02, 2011 at 20:20 UTC | |
|
Re: matching a word a in array of words
by Anonymous Monk on Apr 02, 2011 at 14:42 UTC | |
by Anonymous Monk on Apr 02, 2011 at 14:59 UTC |