On Fri, 22 Nov 2002 15:40:17 +0000 (GMT) Josh Barker <[EMAIL PROTECTED]> wrote:

> I'm trying to pass a url like:
> 
> http://link.clientname.com/path_name
> 
> And get:
> 
> Can't locate object method "host" via package "URI::_generic" at
> ../buggy_program.pl line 17.
> 
> I'm using:
> 
> $url_use = "http://link.clientname.com/path_name";

This line is missing a ';'.

> $url = URI->new($url_use);
> $host_name = $url->host();
> 
> Am I missing something obvious?

Other than no 'use strict;' and '-w' in the '#!' line?

Try single stepping into URI->new() with the Perl debugger.  It's all Perl
code, so you ought to be able to find out why the 'http:' scheme in the URI
isn't getting picked up and converted to the appropriate
implementing class.

I cut and pasted your code into the following script and it works for me
(URI-1.21).  It should work with URI-1.22 since I don't see any changes in
URI.pm that would affect this.

#!/usr/bin/perl -w
use URI;
use strict;

my $url_use = "http://link.clientname.com/path_name";;
my $url = URI -> new( $url_use );
my $host_name = $url -> host();

print "$host_name\n";
exit 0;                

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.




Reply via email to