#!perl -w use strict; my $test = 'foo[bar]'; my $test2 = $test; print $test eq $test2 ? "'$test' is equal to itself\n" : "'$test' is not equal to itself\n"; print $test =~ /$test2/ ? "'$test' does match itself\n" : "'$test' does not match itself\n"; __END__ > perl -w tmp.pl 'foo[bar]' is equal to itself 'foo[bar]' does not match itself