$ perl -MURI -le"print URI->new_abs( '/' => URI->new( shift ))" http://www.abc.com/def/ghi.html?s=d http://www.abc.com/