SPUG: XML::RSS help

jerry gay jerry.gay at gmail.com
Tue Sep 26 15:03:12 PDT 2006


On 9/26/06, luis medrano <lmzaldivar at gmail.com> wrote:
> I have this script:
>
> foreach my $url (@list_of_rss_url){
>
>     my $rss=XML::RSS->new();
>     my $data=get($url)or  die  "Couldn't get it!";# unless defined $data;
>     $rss->parse($data);
>          foreach my $item (@{$rss->{items}}){
>         my $link=$$item{link};
>         my $title=$$item{title};
>         print "$link, $title \n";
>         }
> }
>
> but my problem is I don't want the script to die if the rss is not valid or
> not available when I call it.
>
so, don't C<die>!

  ...
  my $data= get($url);
  unless($data) {
    warn qq{warning: couldn't get "$url"};
    next;
  }
  ...

~jerry


More information about the spug-list mailing list