Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: truncating urls

by Berik (Sexton)
on Feb 19, 2004 at 23:31 UTC ( [id://330406]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://330406]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-16 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found