in reply to Re: Overriding module-internal calls
in thread Overriding module-internal calls

This seems to fix it, though is a bit slow, having to load up LWP::UserAgent to do the work:
use strict; use warnings; use XML::RSS::Tools; use LWP::UserAgent; my $rss_feed = XML::RSS::Tools->new; my $ua = LWP::UserAgent->new; $ua->agent('Camel Power 3.14.15 [rss])'); my $rss = "http://www.perl.com/pace/news.rss"; my $request = HTTP::Request->new(GET => $rss); my $response = $ua->request($request); my $status = $response->status_line; my %errors = ('500'=>'Bad hostname supplied', '501'=>'Protocol not supported', '404'=>'URL not found', '403'=>'URL forbidden', '401'=>'Authorization failed', '400'=>'Bad request found', '302'=>'Redirected URL' ); ($status) = ($status =~ /(\d+)/); if (defined($errors{$status})) { die "ERROR: $errors{$status}\n"; } else { my $content = $response->content; $rss_feed->rss_string($content); $rss_feed->xsl_file('rss.xsl'); $rss_feed->transform; print $rss_feed->as_string; }

I'll hit it with benchmark and see if maybe one of the other feching modules can do the same thing faster. Any suggestions on alternate modules that can do the same thing? What I require is:

  1. Providing a custom UserAgent string
  2. Being able to do HEAD and GET on the URI
  3. Having a proper status_line come back for error trapping

Replies are listed 'Best First'.
Re: Re: Overriding module-internal calls
by Juerd (Abbot) on Apr 22, 2003 at 12:18 UTC

    I'll hit it with benchmark and see if maybe one of the other feching modules can do the same thing faster.

    The speed overhead of ANY way to get the file, even if you fork curl for it, is absolutely irrelevant compared to the overhead of actually requesting the document and waiting for and getting its headers and body.

    Juerd
    - http://juerd.nl/
    - spamcollector_perlmonks@juerd.nl (do not use).