in reply to Re: don't get bit by split.in thread @arrys & Non exact searches.
Replace your grep line with this:
my @matches = grep { $names[$i] =~ /$pattern/ } 0 .. $#names; [download]
"Perl makes the fun jobs fun and the boring jobs bearable" - me