Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone,
In the code below, I wanted to say a word in @inputs is matched to what word in @list. How do I get the word in @list that matches the word in @inputs? That is, how do I replace the ?? with the matched word in @list?
use String::Approx qw(amatch); my @list = qw(Apple Pear Orange); my @inputs = qw(aple appe peay range oranges mango appple aqqple); for my $word (@inputs) { if (amatch($word, ["i"], @list)) { print "Matched: $word to ?? <br />"; } else { print "Unmatched: $word <br />"; } }
Sample output: Matched: aple to ?? Matched: appe to ?? Matched: peay to ?? Desired output: Matched: aple to Apple Matched: appe to Apple Matched: peay to Pear
Thank you for reading and looking forward to your replies.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting matched word from String::Approx
by Athanasius (Archbishop) on Dec 30, 2015 at 12:30 UTC | |
by Anonymous Monk on Dec 30, 2015 at 12:44 UTC | |
by Athanasius (Archbishop) on Dec 30, 2015 at 13:15 UTC | |
by Anonymous Monk on Dec 30, 2015 at 16:17 UTC | |
by ww (Archbishop) on Dec 30, 2015 at 18:45 UTC | |
|