well, if you're looking for an exact match, use eq if ($row eq "$m$names[$k]$m") {...
If you're compelled to use a regex, use anchors to either determine if there's a word in the string that matches your criteria (using the \b anchor) if ($row =~ m|\b$m$names[$k]$m\b| {...
or the entire string using \A and \z :
if ($row =~ m|\A$m$names[$k]$m\z| {...