Latest News

30th July 2007
Send to twitter Send to Facebook

If you are using the Perl module XML::RSS in the following way:

my $R = XML::RSS->new;
foreach my $url (@urls) {
  my $content = wget($url);
  $R->parse($content);
}

In older versions of the XML::RSS module, this code worked fine. However, if you have upgraded the module recently, you might have noticed the error message: Modification of non-creatable array value attempted, subscript -1 at /usr/local/lib/perl5/site_perl/5.8.5/XML /RSS.pm line 792.

It is not the feed that has gone rancid on you, but the library. Try instantiating a RSS object within the loop like this:

foreach my $url (@urls) {
  my $content = wget($url);
  my $R = XML::RSS->new;
  eval{$R->parse($content)};
  if ($@) {
    warn("Parse error: $@");
    next;
  }
}

I've added some "exception" handling for free in this example so that parse errors don't blow up your program.

I'm afraid I did not dive into XML::RSS.pm to figure out the problem, but if someone with that knowledge wishes to post below, I'm sure won't be the only one who welcomes enlightenment.

UGH
:: 31st Jul 2007 - 12:07
:: pudge
I revereted XML::RSS. Note that this one was produced by Shlomi Fish. Not only that, but The Perl Foundation PAID HIM TO DO IT.
Thank God for
:: 31st Jul 2007 - 12:07
:: jjohn
Jeez, you'd think a regression test would have caught this. Perhaps Mr. Fish thought that the XML::RSS should be more stateful than it was? Too bad.
Thanks
:: 3rd Nov 2007 - 14:11
:: Fábio
Thank you! That was what I needed! Now my script is running again! :D

About this blog

The taskboy blog is a exploration of computer technology by Joe Johnston. Topics of posts include practical examples Perl, PHP, Python and Java as well as book reviews, industry insights and miscellaneous good stuff.

Current Status

Watching _Brass Latern_. Ah IF, your coyness is your charm.

Posted: Sun Sep 05 16:02:15 +0000 2010