Hans de Graaff <[EMAIL PROTECTED]> writes:

> I think the problem is that host() is only supported for those schemes
> that have an authority component (see perldoc URI for more
> details). It would be nice if there would be a simple test to
> determine which schemes qualify for this. Currently I have this
> hardcoded in my application to do this:
> 
>     $url->host(ip_address($url->host)) if $url->scheme =~ 
>/^(https?|ftp|gopher|https|ldap|news|nntp|pop|rlogin|snews|telnet)$/;
> 
> I'd be happy to learn of a better way to do this, and I'm sure my list
> is not complete anyway.

I suggest either:

    $url->host(ip_address($url->host)) if $url->can("host");

or:

    if (my $host = $url->can("host")) {
        &$host($url, ip_address(&$host($url)));
    }

or:

    eval { $url->host(ip_address($url->host)) };
    die $@ if $@ && $@ !~ /^Can't locate object method "host"/;


Regards,
Gisle

Reply via email to