[lug] perl LWP problem
dan radom
dradom at redback.com
Mon Dec 17 11:43:32 MST 2001
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";}
More information about the LUG
mailing list