in reply to modify a URL

A way, with URI (this is not complete, fragments and queries must be dealt with too; read the docs to see how and write some tests to be sure it's behaving as you expect).

perl -MURI -le '$u = URI->new(shift); $u->path(undef); print $u' http: +//www.abc.com/def/ghi.html http://www.abc.com

Replies are listed 'Best First'.
Re^2: modify a URL
by Anonymous Monk on Nov 04, 2010 at 23:27 UTC
    $ perl -MURI -le"print URI->new_abs( '/' => URI->new( shift ))" http:/ +/www.abc.com/def/ghi.html?s=d http://www.abc.com/