Google Answers Logo
View Question
 
Q: PERL: relative to absolute URLs ( No Answer,   0 Comments )
Question  
Subject: PERL: relative to absolute URLs
Category: Computers > Programming
Asked by: marcfest-ga
List Price: $20.00
Posted: 10 Feb 2004 15:00 PST
Expires: 11 Feb 2004 13:56 PST
Question ID: 305511
I need a perl function ("make_absolute")that turns all relative URLs
in an html document into absolute URLs, using the URL from which the
document was fetched as an argument. As an answer to this question,
please fill in the code for the function "make_absolute" in the script
sample below. Thank you.
Marc.

$content = get ($url);

$content = &make_absolute ($content, $url);

print $content; exit;

sub make_absolute {


}

Request for Question Clarification by webadept-ga on 10 Feb 2004 16:04 PST
So you want img tags and a tags? href's and src's ? 

I'm working on this now, with that in mind. If there are other tags
you want besides those two, let me know.

webadept-ga

Clarification of Question by marcfest-ga on 10 Feb 2004 18:52 PST
Yes, any relative url should become absolute. 

The URI class looks like it would be most useful for this.

Thanks.

Request for Question Clarification by webadept-ga on 11 Feb 2004 03:18 PST
I was just going to ask if you could use the URI and the
HTML::LinkExtor class as well.. since it appears you can, then I'll
rewrite this using those. These are much better to use than a regex,
since many things can happen in a page which would cause a regex to
fail, or worse, put the url in there when it wasn't needed.

Clarification of Question by marcfest-ga on 11 Feb 2004 03:25 PST
Yes, I can use these modules.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy