in reply to Changing .html to .asp on some links but not others

First, you really should fix your web pages to put quotes around your hrefs: s/href=([^"\s>]+)/href="$1"/g because your current code will fail for cases like: <a href="http://www.google.com/">Google</a> uses .html files.

to name just one of many problem cases.

Easy way:

s/(href="[^"]*)\.html"/$1.asp"/g s/(href="http://[^"]*)\.asp"/$1.html"/g
but that breaks if you already have some external links that end in ".asp".

Better:

s{(href="[^"]*\.html")}{ my $s= $1; $s =~ s#\.html"$#.asp"# unless $s =~ m#^http:#; $s }ge;

Oh, and I hope you don't have href=x outside of <a> tags in any of your web pages. (:

        - tye (but my friends call me "Tye")