in reply to Infinite recursion for iterator of tied hash with perldbmfilter for filter_fetch_key

I have found the issue: During the tests I recognized that filter_fetch_key calls my function once with a key value of undef and my functions return an empty string for convenience in that case. This seems to be what's causing the infinite loop, I guess someone wants to add that empty string as a new key to the hash for some reason and runs into problems with some iterator which gets invalid or such. The interesting part about that is that changes to keys should be perfectly fine, because one of the examples in the documentation is exactly about that and my tests show that I can replace each key except the undef one which whatever I like, I can create completely new keys by prepending __ for example. No problem, only if I don't return undef for undef I get the infinite loop. The first version of the following method works, the second does not.

sub _normalizeCharset { my $self = shift || Carp::croak(...); my $value = shift; my $key = shift || 0; return undef unless (defined($value)); #return '' unless (defined($value)); $value = "__$value" if ($key); return ...::windows2utf($value); }
sub _normalizeCharset { my $self = shift || Carp::croak(...); my $value = shift; my $key = shift || 0; #return undef unless (defined($value)); return '' unless (defined($value)); $value = "__$value" if ($key); return ...::windows2utf($value); }

I guess undef may be some special signal of the filter to indicate the end of iterated keys or such and simply is not meant as a regular hash key. At least I don't put it anywhere.

  • Comment on Re: Infinite recursion for iterator of tied hash with perldbmfilter for filter_fetch_key
  • Select or Download Code