In my last entry I mumbled something about a tricky bug in perl that was allegedly unreportable. Good so because as it turned out, it wasn't a bug at all. I had this kind of setup:
sub search {
my ($self, $state) = @_;
...
# $state->{last_search} being an array-ref of previous
# search patterns. You were supposed to cycle through them
# with TAB
my $pattern = $self->get_input($state, $state->{last_search});
...
# once a list of matchings songs has been returned and the user
# chose one of them to play
$state->playlist->play;
}
sub get_input {
my ($self, $state, $searches) = @_;
...
if ($hit_key == KEY_TAB) {
push @$searches, shift @$searches;
goto &search;
}
...
return $search_pattern;
}
goto &func replaces the running instance of a function with &func. When looking at search() it becomes obvious that this would eventually expand to:
my $pattern = $self->search($state);
$pattern would contain the return value of search which would be its last value evaluated ($state->playlist->play always returns 1). Now I changed things so that get_input does a goto &get_input instead. goto &func would be one of those less harmful things. But in fact, it's even worse than anything Dijkstra described in his pamphlet.