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.