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.


In reply to Re: Infinite recursion for iterator of tied hash with perldbmfilter for filter_fetch_key by Pickwick
in thread Infinite recursion for iterator of tied hash with perldbmfilter for filter_fetch_key by Pickwick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.