# This reg expression will do the trick, and doesn't bold things inside <> tags such as # URL's. $link_results =~ s,(<[^>]+>)|(\Q$term\E),defined($1) ? $1 : "$2",gie;