Subject: | Undefined namespace in |
When using xml-elemental to parse ATOM feeds I often get this error
reported by the code:
Use of uninitialized value in pattern match (m//) at
/usr/lib/perl5/vendor_perl/5.8.8/XML/Parser/Style/Elemental.pm line 87
This is in the ns_qualify routine. The underlying problem is if
namespaces are used, but the specific namespace isn't found then
an undefined values is used in a m//. I avoided the errors by putting
an extra test for a null namespace before the match.
Here's the revised routine from Elemental.pm, with the added line
marked with >>>
sub ns_qualify {
return $_[1] unless $_[0]->{Namespaces};
my $ns=$_[0]->namespace($_[1]) ||
( $_[2] ? $_[0]->namespace($_[2]) : return $_[1] );
Show quoted text
>>> return $_[1] if ! defined($ns);
$ns=~m!(/|#)$! ? "$ns$_[1]" : "$ns/$_[1]";
}