[lug] perl LWP problem

Walter Pienciak walter at frii.com
Mon Dec 17 17:28:10 MST 2001


On Mon, 17 Dec 2001, dan radom wrote:

> I've got a small problem with the below code.  When I uncomment the "use LWP::Simple qw(get $ua);"
> and "$ua->timeout(25);" lines the script completely ignores the getopts portion.  The script does
> timeout in 25 seconds like it should, but it never performs the $file get.  If I run it as is
> with either the -p or -o option it works fine.
>
> Has anyone used a timeout with LWP::Simple, or would I be better off using LWP::UserAgent?
>
> Dan
>
>
> #use LWP::Simple qw(get $ua);
> #$ua->timeout(25);
> use LWP::Simple;
> use Getopt::Std;
> getopts('o:p', \%args);
>
>
> if (exists($args{p})) {
>   $ENV{http_proxy} = "http://localhost:8080";}
>
> my $outfile = "mutt-rb";
> my $file = get("http://redweb.redback.com/directory/dir-pdas.csv")
>     || die "can't download data file.  perhaps you need to use the proxy flag.\n";
>
> @t=(split/\n/,$file);
>
> unless (exists($args{o})) {
>   open STDOUT, ">$outfile" or die "can't open $outfile\n";}

That method call '$ua->timeout(25)' is not supported in LWP::Simple,
which exports only the following:  get head getprint getstore mirror.

So, yes, I'd go with LWP::UserAgent.

Walter




More information about the LUG mailing list