[Linux-disciples] Re: Converting relative links to absolute

Stephen R Laniel steve at laniels.org
Wed Sep 1 15:59:29 EDT 2004


On Wed, Sep 01, 2004 at 03:41:47PM -0400, Stephen R Laniel wrote:
> This might do it:
> http://search.cpan.org/dist/URI/URI.pm

It did. Just to pass along some cool information, I did
something like the following. Assume I've already downloaded
a page $urlOne, and extracted a URL inside of it called
$url2. Suppose $url2 is relative. To make it absolute
and stuff the absolute URL into $url3, we can do

use URI;
my $url3 = URL->new_abs($url2,$urlOne)->canonical;

That's it. The URI library is smart enough to know that when
you type

print "URL3 is $url3\n";

you want $url3 to be a string; you don't need to do
$url3->as_string, though you could.

Just some helpful words, should they ever come in handy for
anyone.

-- 
``You see, Andrew: toilet paper is made of paper, while rats
  are made out of ... rat.''
 -Josh Wretzel, 2004-08-29



More information about the Linux-disciples mailing list