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.

In reply to Getting matched word from String::Approx by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":