in reply to Re: Iterating hash of blessed hashes
in thread Iterating hash of blessed hashes
my $hr = $tvdb->getSeriesBanners($title, 'season', 'seasonwide'); my $rating = 0; my $bwurl; my @keys = keys %$hr; foreach my $id (@keys) { my $hr2 = $hr->{$id}; if (($hr2->{Season} == $seasonnum) && ($hr2->{Rating} > $rating)) +{ $rating = $hr2->{Rating}; $bwurl = $hr2->{BannerPath}; } } if ($bwurl) { debug(1, "Using highest rated Series Banner\n"); return "http://thetvdb.com/banners/_cache/$bwurl"; }
In which I now see a bug: If the only banner(s) available have a zero Rating, I end up with nothing. I'll change it to -1.
The Rating is a 0..10 scale AFAIK (Thetvdb.com via TVDB::API), and I always use strict; use warnings;
|
|---|