develooper Front page | perl.libwww | Postings from November 2002

Re: URI Bug?

Thread Previous | Thread Next
Darby Cacdac
November 23, 2002 10:39
Re: URI Bug?
Message ID:
Lemme give you a code sample:


use URI::URL;
$attr_value = "products/index.html";  # This is a valid relative link!
$url = url $attr_value;
$host = $url->host;

Running the above code generates the error below. In my mind it 
shouldn't produce an error because $attr_value is a valid url (even if 
it doen't have the host element explicitly included). In the above case, 
I'm expecting   $url->host to return null or undefined but not a lousy 
error message!

If you were to change the $url->host line above to  to $url->scheme or 
$url->frag, no errors are generated  so why generate and error when you 
try to get the host portion? There has to be consistency.

The issue really here is not about and invalid scheme or URL. It is 
about providing consistent behavior in the URI::URL class interface.

Thurn, Martin wrote:

>>"Can't locate object method "host" via package 
>>"URI::_generic" (perhaps you forgot to load "URI::_generic"?) 
>That's the error you get whenever you try to create a URI with a scheme that
>it doesn't know about.  You should either check the scheme yourself, or wrap
>the 'new URI' in an eval.
>Perl & LWP book
> - - Martin 'Kingpin' Thurn 

Darby Cacdac                    Sun Microsystems, Inc.
TE - Advance Engineering        901 San Antonio Road, USJC06-203
eMail:    Palo Alto, California  94303
  Tel:  (408) 635-0808

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About