From: "Timothy Johnson" <[EMAIL PROTECTED]>
> When I try to do a pattern match on a variable that contains a '[', I
> get the following error:
>
> Unmatched [ before HERE mark in regex m/target[ << HERE / at
> C:\PerlScripts\test.pl line 5.
>
> Here is my code so far:
>
> $line = "my target[ target ]";
>
> $t = "target[";
> if($line =~ /$t/){
> print "yes";
> }
>
> I've tried escaping the bracket, etc, etc, to no avail. Any
> suggestions?
Either
$t = "target\\[";
if($line =~ /$t/){
or
$t = "target[";
if($line =~ /\Q$t\E/){
if the $t is not supposed to contain a regexp, but just some text to
search for I'd recoment the second syntax.
Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]