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

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?

Replies are listed 'Best First'.
Re^4: Normal regexes stop working
by Corion (Patriarch) on Oct 24, 2010 at 18:58 UTC
    #!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.