in reply to substitution preserving capitilization

Here is one solution:
my @term= ("My Cat", "your CAt", "thiS CAT", "THAt caT", "their cAT", +"dead cAt", "cAtostrophic cat"); my $search='cat'; for ( @term ) { s!\b($search)\b!<a href=x>$1</a>!i; print $_,$/; }

This finds all "cat"s (the i at the end of the regular expression makes it case insensitive.), captures them and puts them into $1, and then prints them so you can see what has changed. The \b on both sides insures that there is a word boundary on both sides of cat so things like catostrophic are not changed. Note that this will only capture one cat per line you need to add a g at the end of the regular expression if you want to catch more.

-enlil