Is this what you are looking for?
When the following is run...
use URI; $u1 = URI->new('http://www.comp.leeds.ac.uk/Perl/'); $u2 = URI->new('http://www.comp.leeds.ac.uk/Perl/filehandling.html'); print "u1.host=",$u1->host(),"\n"; print "u2.host=",$u2->host(),"\n"; if ($u1->host() eq $u2->host()) { print "URL's host are the same\n"; } else { print "oops\n"; }
It produces the follwing output...
u1.host=www.comp.leeds.ac.uk u2.host=www.comp.leeds.ac.uk URL's host are the same
It doesn't use URI::URL, but I'm not sure that you need to.

Update:
The URI perldocs have a section on parsing URI's with a regex. Here's a cut of that section...
PARSING URIs WITH REGEXP As an alternative to this module, the following (official) regular exp +ression can be used to decode a URI: my($scheme, $authority, $path, $query, $fragment) = $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:# +(.*))?|; The URI::Split module provide the function uri_split() as a readable a +lternative.


Update:
To get around the problems of case you could use the URI canonical method like...
use URI; $u1 = URI->new('http://www.comp.Leeds.ac.uk/Perl/')->canonical(); $u2 = URI->new('http://www.comp.leeds.ac.uk/Perl/filehandling.html')-> +canonical(); print "u1.host=",$u1->host(),"\n"; print "u2.host=",$u2->host(),"\n"; if ($u1->host() eq $u2->host()) { print "URL's host are the same\n"; } else { print "oops\n"; }

In reply to Re: Using URI::URL to determine resources within a site by mifflin
in thread Using URI::URL to determine resources within a site by sutch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.