Subject: | [PATCH] Silence "undefined value" warning in feed processing |
When playing with dipsy on #p5p, I ran into the following oddness.
08:05 <+dipsy> advice from klortho is << Error parsing RSS from
http://www.dave.org.uk/klortho_rss.cgi: Can't call method
"entries" on an undefined value at
/usr/local/lib/perl5/site_perl/5.8.7/Bot/BasicBot/Pluggable/Module/Infobot.pm
line 431.
08:05 <+dipsy> .. >>
The following patch should silence this.
--- lib/Bot/BasicBot/Pluggable/Module/Infobot.pm.old Fri Aug 10 08:14:36 2007+++
lib/Bot/BasicBot/Pluggable/Module/Infobot.pm Fri Aug 10 08:15:13 2007@@ -367,7
+367,9 @@
my @items;
eval {
my $feed = XML::Feed->parse( URI->new( $url ) );
- @items = map { $_->title } $feed->entries;
+ if(defined $feed) {
+ @items = map { $_->title } $feed->entries;
+ }
};
return "<< Error parsing RSS from $url: $@ >>" if $@;