take a look at
HTML::LinkExtor. Its part of html::parser.
it has a sample script that grabs a list of the img tags files from a given url. should be fairly simple to expand this to grab everything linked. then you just have to go through the grabbed document and rewrite any absolute links into relative one. should just be a case of using an regex.
of course, there are premade scripts/programs to do this. you just have to decide if they do what you want, and if you want to reinvent the wheel.(contrary to popular belief, there are reasons to do this. its a good way of learning new modules. if you have time that is)