Everybody explained why
map doesn't mix too well with
s/// and how you want a different delimiter than the forward slash there, but what I wonder is why you're using
map at that point at all? It would be far simpler to say
while (my @row = $sth->fetchrow_array()) {
s!$term!"<i>$term</i>"! for @row;
# ...
}
You also probably want to escape pattern metacharacters in $term (
s!\Q$term!"<i>$term</i>"!, perldoc -f
quotemeta), and it might help to precompile the pattern:
my $rx = qr/\Q$term/;
while (my @row = $sth->fetchrow_array()) {
s!$rx!"<i>$term</i>"! for @row;
# ...
}
Makeshifts last the longest.