in reply to truncating urls

Problem here is that you can't be sure that the new link would still work. This depends on server configuration, and the files present in the directory.

For example, if you're substituting index.htm. And there is a file called default.html in thesame dir, and the server is configured to first look for a file called default.html. You'll get the default.html, not what you'd expected.

Anyway, your looking for a substitution like this:
$url =~ s-(?<=/)index\.htm(?=(\?|$))--;

This checks wheter index.htm is preceded by a '/' and 'end of string' or a '?' must follow it.

You could also have a look at URI, this module uses the official URL matching rules.

---
Berik