- my $results= $sth->fetchall_arrayref();
- if (!@$results) {
- $err->('no island or arch matches "%s"');
- } elsif (@$results > 3) {
- $err->(' ');
- } elsif (@$results > 1) {
- my @m= map { $_->[2] } @$results;
- $err->('ambiguous island or arch "%s", could be '.
- join(', ', @m));
+ my @m;
+ my $results;
+ foreach my $pat ("$each\%", "\%$each\%") {
+ $sth->execute($pat,$pat);
+ $results= $sth->fetchall_arrayref();
+ last if @$results==1;
+ push @m, @$results;
+ $results= undef;
+ }
+ if (!$results) {
+ if (!@m) {
+ $err->('no island or arch matches "%s"');
+ } elsif (@m > 3) {
+ $err->(' ');
+ } else {
+ $err->('ambiguous island or arch "%s", could be '.
+ join(', ', map { $_->[2] } @m));
+ }