[sword-devel] Perl Sword string comparison problem

Peter von Kaehne refdoc at gmx.net
Thu Sep 3 13:12:14 MST 2015


I am trying to take a string, pack it into a SWBuf, take a copy of it
into another SWBuf, run the copy through a stripfilter and then compare
the string content of the outcome with the initial string:


   my $tmp = new Sword::SWBuf();
   $tmp=$doc_text; # where $doc_text is a SWBuf, obtained earlier.
   $manager->filterText($filter, $tmp);

   if ($tmp->c_str() ne $doc_text->c_str()) {
      print "GlobalOptionFilter=".%diacritics{$filter}."\n";
   }                      
   else { print "NotPresent=".%diacritics{$filter}."\n";
   }

For reasons which are beyond me, it always runs down the "else" path. 

Despite the string in $doc_text having plenty of the stuff which I want
to filter.

Despite if I strew liberally print statements the two strings clearly
being different, i.e. "unfiltered" vs "filtered"

Despite if I compare by hand two strings the "ne" operator doing its
job just fine.  "a" ne "b" or indeed "unfiltered" ne "filtered"

My forehead is bloodied by the frequency I have hit it against the
wall.

Suggestions?

Thanks

Peter



More information about the sword-devel mailing list