s{ http://www\.something\.com/something # the URL you are looking for # remeber to backslash '.' (?!\w) # a negative look-ahead assertion # do not allow a dirname of 'somethinglong' /? # an optional slash } # end of search pattern { # replace with http://www.something.com/something/index.html }gx