in reply to Re: Normal regexes stop working
in thread Normal regexes stop working

Sorry, I didn't mean the perl form of tainted--but the english form. I can literally set the strings to the same value and it fails. Also weird, I can detect that failure case, and branch code there and do a new regex with the same variables and that one succeeds.

Replies are listed 'Best First'.
Re^3: Normal regexes stop working
by JavaFan (Canon) on Oct 24, 2010 at 17:12 UTC
    If you keep refusing to give actual example values, or even better, a small stand alone code sample that exhibits the problem, I do not think you'll get anywhere near a useful answer.
      Sorry, I didn't mean to come off as refusing anything. It's just that it is intermittent. So you run the same code block the first many times and it works fine, and then at some point in there it fails and then fails thereafter. Here's the most recent failure.
      my $q_meta = quotemeta($q); my $tmp_test = ($page_title =~ /$q_meta/i) || 0; if (!$tmp_test) { my $tmp_test2 = lc $page_title eq lc $q; $is_exit = 1 if $tmp_test2; my $tmp_test3 = is_utf8($page_title); my $tmp_test4 = is_utf8($q); # For debugging. if ($is_dilbert) { warn qq(\nDILBERT 1a\t$page_title\t$q_meta\t$tmp_tes +t\t$tmp_test2\t$tmp_test3\t$tmp_test4\n") if \ $is_dilbert; }

      produces DILBERT 1a      Polygram compilation albums     Polygram\ compilation\ albums   0       1       1       1

        So whats $q? $page_title? This is the important part, the bytes that go into these values, its probably invisible whitespace or nonbreaking whitespace that is tripping you up (they just look like whitspace, but are different bytes)
        That's neither values for $test and $test2, nor a stand alone piece of code.

        I'll just give up on you.

Re^3: Normal regexes stop working
by yegg (Acolyte) on Oct 24, 2010 at 17:10 UTC
    As a double check I also had it do $test eq $test2 when printing out this error case, and that evaluated to 1. When could that work but $test =~ /$test2/ fail?
      #!perl -w use strict; my $test = 'foo[bar]'; my $test2 = $test; print $test eq $test2 ? "'$test' is equal to itself\n" : "'$test' is n +ot equal to itself\n"; print $test =~ /$test2/ ? "'$test' does match itself\n" : "'$test' doe +s not match itself\n"; __END__ > perl -w tmp.pl 'foo[bar]' is equal to itself 'foo[bar]' does not match itself

      Also see quotemeta and/or \Q..\E.