[ic] LWP::UserAgent error

daniel castro daniel_castro at hotmail.com
Fri May 13 15:36:17 EDT 2005


> >Thanks for the reply, changing to UserAgent really helped, also the 
>::LogError, now the error log shows this:
>
> >157.253.41.19 6KJERhED:157.253.41.19 - [13/May/2005:16:42:13 +0000] 
>plcost /cgi-bin/plcost/test.html Runtime error: Can't locate object method 
>"get" via package 
>"http://>www.larepublica.com.co/inc/imagenes/indicad.php?env=7m9r5j5c" 
>(perhaps you forgot to load 
>"http://www.larepublica.com.co/inc/imagenes/indicad.php?env=7m9r5j5c"?) at 
>(tag >'exchange_rate') line 7.
>
> >I have no idea how to solve this.
>
>You need to review the syntax for using LWP::UserAgent, it's more 
>complicated than that for simple.
>Use something like:
>
>     my $page;
>     my $browser = LWP::UserAgent->new;
>     $browser->timeout(10);
>     my $response = $browser->get( $url );
>     if($response->is_success){
>	$page = $response->content;
>	return $page;
>     } else {
>	# ERROR
>	 return $response->status_line;
>     }
>

Turned out like this:
UserTag exchange-rate Order currency
UserTag exchange-rate PosNumber 1
UserTag exchange-rate Routine <<EOR
sub {

my ($currency) = @_;
my $url;
my $browser = LWP::UserAgent->new;
$browser->timeout(10);
$url = 
'http://www.larepublica.com.co/inc/imagenes/indicad.php?env=7m9r5j5c';
my $response = $browser->get( $url );
  if($response->is_success){
        my $content = $response->content;
        my $string = "TRM=";
        $content = substr ( $content , rindex ($content, $string)+4, '8');
        $content = substr ( $content , rindex ($content, $string)+4, '5');
        $content = 1 / $content;
        return $1;
    } else {
# ERROR
return $response->status_line;
    }

}
EOR

>or something ...
>
>see
>perldoc LWP::UserAgent for more info.
>
>Bryan
>
><a href="http://www.neartexpress.com">Posters and Art Prints</a>
>
>_______________________________________________

And now I am getting this:
500 Can't connect to www.larepublica.com.co:80 (Bad protocol 'tcp')

The wierd part, is that If I run this usertag (with some mods) outside 
interperl, in pure perl, it runs fine. So I can only asume that the problem 
is IC. any guess?

At least nos it look more profewsional :P

Thanks for all the help.
Daniel




More information about the interchange-users mailing list