Subject: | Infinite loop |
Date: | Fri, 23 Jan 2009 11:21:24 +0100 |
To: | bug-WWW-Gazetteer-HeavensAbove [...] rt.cpan.org |
From: | Henry Ayoola <henry.ayoola [...] googlemail.com> |
I noticed that a certain query with Gazetteer-HeavensAbove seemed to be
taking rather a long time, and then I discovered that it was spinning
through the same cities again and again. The code for splitting up a large
query into multiple ones seems to have a problem with the ß character.
Here's a test case. Forgive me if the style isn't very idiomatic - Perl is
at best my third language.
#!/usr/bin/perl
use WWW::Gazetteer::HeavensAbove;
my $atlas = WWW::Gazetteer::HeavensAbove->new;
my %seenmap;
my $cb = sub {
local $, = "\t";
local $\ = $/;
local $line;
foreach $foo (@_) {
$line = join(':', @$foo{qw(name latitude longitude)});
die "Seen '$line' twice" if $seenmap{$line} > 1;
warn "Seen '$line' once" if $seenmap{$line} > 0;
$seenmap{$line}++;
}
};
# Demo of it not breaking. A single city is seen twice.
$atlas->find('A*', 'DE', $cb);
# Demo of it breaking. A lot of cities are seen twice, and then it loops
again.
$atlas->find('Gro*', 'DE', $cb);
# End test case
Version information:
Version 0.16 of WWW::Gazetteer::HeavensAbove (downloaded directly from CPAN)
Perl version 5.10.0 built for i486-linux-gnu-thread-multi (dpkg reports
5.10.0-16)
Linux 2.6.26-1-686 #1 SMP i686 GNU/Linux
Debian lenny
dpkg reports libwww-perl (LWP) as version 5.813-1
I'm executing the test script from GNU bash version 3.2.39(1)-release
(i486-pc-linux-gnu)
with locale es_ES.UTF-8
Hope that's enough info for you to reproduce it.
Yours,
Henry Ayoola