in reply to Normal regexes stop working

Tainted has nothing to do whether regexes match or not. I expect the variables either don't contain what you expect, or $test2 contains one or more characters that are special to the regular expression engine.

Do you have an example of a $test and a $test2 that you expect to match, but don't?

Replies are listed 'Best First'.
Re^2: Normal regexes stop working
by yegg (Acolyte) on Oct 24, 2010 at 17:04 UTC
    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.
      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

      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.