SPUG: XML::RSS help

Steve Baylis sbaylis at gmail.com
Tue Sep 26 15:09:45 PDT 2006


I've never used XML::RSS but it's possible that it could die if you try to
parse bad XML.  If it does, you may want to also do:

eval {
    $rss->parse($data);
};
if ( $@ ) {
    warn "Could not parse data\n";
}

-Steve

On 9/26/06, jerry gay <jerry.gay at gmail.com> wrote:
>
> 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
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays
>     WEB PAGE: http://seattleperl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20060926/3c51a2aa/attachment.html 


More information about the spug-list mailing list