develooper Front page | perl.beginners | Postings from April 2002

matching a [ in a regex

Thread Next
From:
Timothy Johnson
Date:
April 2, 2002 10:06
Subject:
matching a [ in a regex
Message ID:
C0FD5BECE2F0C84EAA97D7300A500D5002581223@SMILEY

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?

Tim Johnson
SanDisk



--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About