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

You need to add a regex check in the spot where you already determined it should be. I recommend it look like this:
if ($_ !~ m/href=\"http:\/\/.+\.html/) { s/(href=.+?\.)html/$1asp/gi }
Warning: the regex is untested but I believe it should work provided the links have quotations around the URL's.

-Adam Stanley
Nethosters, Inc.

Replies are listed 'Best First'.
Re: Re: Changing .html to .asp on some links but not others
by isotope (Deacon) on May 02, 2001 at 01:15 UTC
    Given that he's reading one line at a time, this solution says:
    If the current line does not contain the string href="http://[anything].html then replace every instance (on this line) of href=[anything].html with href=[anything].asp
    If there are multiple links on one line, and any one of them is external, this solution will skip all links on that line. If a link spans more than one line, it will not be handled properly. After looking at this same problem posted here what, 4 times now, I'm thinking maybe the best approach is to use HTML::TokeParser, analyze each link (using the convenient get_tag method), and rewrite the HTML with CGI or something so it's nice and pretty.

    --isotope
    http://www.skylab.org/~isotope/