Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

(ichimunki) Re: Handling relative urls with LWP or something else

by ichimunki (Priest)
on Dec 19, 2001 at 21:19 UTC ( #133177=note: print w/replies, xml ) Need Help??


in reply to Handling relative urls with LWP or something else

While you might want to keep merlyn's columns in mind as good reading and a source of (hopefully) good examples using common CPAN modules, you might also want to check the POD for URI. And I quote:

$uri = URI->new_abs( $str, $base_uri )
This constructs a new absolute URI object. The $str argument can denote a relative or absolute URI. If relative, then it will be absolutized using $base_uri as base. The $base_uri must be an absolute URI.

So if you know the URL of the page you got the URL from, you know $base_uri. A simple test like $url =~ /^http/ should let you know whether you've gotten an absolute URL or not. Of course, testing is not necessary as the constructor will gladly ignore the $base_uri if $str is absolute. Or so sayeth the POD anyway.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://133177]
help
Chatterbox?
[GotToBTru]: i guess it's a placeholder, the code will only fill it in if there is nothing else to use
[GotToBTru]: but then .. if you have nothing to say, why not say nothing?
[MidLifeXis]: I have a user who has a lot of say on how some of our processes work that abhors significant blanks. Perhaps that is a part of it. A not-so-obvious "this space intentionally left blank" indicator.
[MidLifeXis]: On the back end, however, that doesn't mean that i have to use that value to indicate "undefined", no matter how much he thinks I should.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-01-20 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (176 votes). Check out past polls.