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