I currenty have a program that takes an entire HTML document, and then replaces one word with another. The problem is if the word is the source of an image tag, the image source is no longer right. The translating line is currently:
$d =~ s/$lookfor/$replace/gim;
How could I make it so it won't replace it if it's in a tag, or between script, title, or other tag?