Bowing to higher level of knowledge, I am working with solid-rock DB_File module, but something cracked my faith: i tried to ovverride $DB_BTREE->{'compare'} routine with a String::Approx 'adist' one. Belief and RTFM suggested to create a 'callback' with an easy template, something like ... "hey man these are 2 parameters, do some kind of comparison and give me back -1, 0 or 1" as the 'cmp' example on documentation..." so, after checking out the only working example routine with case-insensitive comparison on manual, i tried mine:
# ------------------------- sub DBFile_Compare_Distance #-------------------------- { my ($k1, $k2) = @_ ; my $dist = adist ( uc $k1 , uc $k2 ); my $val = undef; if( $dist < -1 ) { $val = -1; } elsif( $dist > 1 ) { $val = 1; } else { $val = 0; } $val; }
- .db file gets created and i checked the binaries
- all data seem to fit
BUT
when i try to read out key/value pairs, i got "undef" on values for which comparison function returned -1.
Any clue on how to make a Compare function different from the one on manual?
many prayers are rising towards the Monastery
thanks igor

In reply to looking for inspiration on 'compare' by zioigor

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.