There could be more than one word matched, so try this:

#! perl use strict; use warnings; 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) { my @matches = amatch($word, ['i'], @list); if (@matches) { print "Matched: $word to: ", join(', ', @matches), "\n"; } else { print "Unmatched: $word\n"; } }


22:27 >perl Matched: aple to: Apple Matched: appe to: Apple Matched: peay to: Pear Matched: range to: Orange Matched: oranges to: Orange Unmatched: mango Matched: appple to: Apple Unmatched: aqqple 22:27 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

In reply to Re: Getting matched word from String::Approx by Athanasius
in thread 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":