Subject: | Uninitialized value -- bug report and a patch to fix it |
1.02 displays a warning on line 1432 on some rss feeds (yahoo top stories for instance). My perl version is 5.8.0, but it looks like it's going to be the same in all versions.
The following patch will fix it:
--- lib/RSS.pm.orig-1.02 2003-02-20 11:19:07.000000000 -0800
+++ lib/RSS.pm 2004-01-04 23:38:44.000000000 -0800
@@ -1427,7 +1427,9 @@
my $self = shift;
my $el = shift;
my %attribs = @_;
-
+
+ my $ns=$self->namespace($el);
+
# beginning of RSS 0.91
if ($el eq 'rss') {
if (exists($attribs{version})) {
@@ -1475,8 +1477,6 @@
# beginning of item element
} elsif ($el eq 'item') {
# deal with trouble makers who use mod_content :)
- my $ns = $self->namespace( $el );
-
if (
(!$ns && !$self->{rss_namespace}) ||
($ns eq $self->{rss_namespace})
@@ -1503,12 +1503,11 @@
$self->{'modules'}->{'http://purl.org/rss/1.0/modules/taxonomy/'} = 'taxo';
}
# beginning of a channel element that stores its info in rdf:resource
- elsif ( exists( $rdf_resource_fields{ $self->namespace($el) } ) and
- exists( $rdf_resource_fields{ $self->namespace($el) }{ $el } ) and
+ elsif ( $ns and
+ exists( $rdf_resource_fields{ $ns } ) and
+ exists( $rdf_resource_fields{ $ns }->{ $el } ) and
$self->current_element eq 'channel' )
{
- my $ns = $self->namespace( $el );
-
if ( $ns eq $self->{rss_namespace} ) {
$self->{channel}->{$el} = $attribs{resource};
}
@@ -1523,12 +1522,11 @@
}
}
# beginning of an item element that stores its info in rdf:resource
- elsif ( exists( $rdf_resource_fields{ $self->namespace($el) } ) and
- exists( $rdf_resource_fields{ $self->namespace($el) }{ $el } ) and
+ elsif ( $ns and
+ exists( $rdf_resource_fields{ $ns } ) and
+ exists( $rdf_resource_fields{ $ns }->{ $el } ) and
$self->current_element eq 'item' )
{
- my $ns = $self->namespace( $el );
-
if ( $ns eq $self->{rss_namespace} ) {
$self->{'items'}->[$self->{num_items}-1]->{ $el } = $attribs{resource};
} else {