Subject: | XML::RSS example incorrect / limited (should pop, not shift) |
Date: | Fri, 12 Sep 2008 15:33:45 -0400 |
To: | bug-XML-RSS [...] rt.cpan.org |
From: | "Dave Baker" <dave [...] dsb3.com> |
http://search.cpan.org/dist/XML-RSS/lib/XML/RSS.pm
The following code fragment appears incorrect:
# ... and removes the oldest item if there are already 15 items
shift(@{$rss->{'items'}}) if (@{$rss->{'items'}} == 15);
The shift() should be a pop() to remove the oldest, not the newest.
Also it might be more expected to shrink to desired size rather than
just take the top one off (hence the while, not the if).
# ... shrink to limited number of items
pop(@{$rss->{'items'}}) while (@{$rss->{'items'}} >= 15);
Dave