#!/usr/bin/perl
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
http://www.amazon.com/exec/obidos/ASIN/0596001789/thestarwarscol06
--
- - Martin 'Kingpin' Thurn
-- -----------------------------+o0o+----------------------------- Darby Cacdac Sun Microsystems, Inc. TE - Advance Engineering 901 San Antonio Road, USJC06-203 eMail: [EMAIL PROTECTED] Palo Alto, California 94303 Tel: (408) 635-0808 http://www.sun.com
