Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!uunet!ncrlnk!ncr-mpd!Mike.McManus From: Mike.McManus@FtCollins.NCR.com (Mike McManus) Newsgroups: comp.lang.perl Subject: Re: Parens in a reg exp Message-ID: Date: 12 Sep 90 12:52:18 GMT References: Sender: uucp@ncr-mpd.FtCollins Distribution: comp Organization: NCR Microelectronic Products, Ft. Collins, CO Lines: 43 In-reply-to: Mike.McManus@FtCollins.NCR.com's message of 12 Sep 90 08:16:52 GMT In article Mike.McManus@FtCollins.NCR.com (Mike McManus) writes: > I'm reading tokens in from a file and doing compares on the token, sort of > like: ... > The problem I run into is when $token is something containg a meta character. > Specifically, things die when $token = "IF(". Anybody got any ideas about a > work around? I tried some things, but am a green enuff novice that I didn't > have much luck. I am having similar problems when comparing tokens that contain other meta characters (such as brackets). Right now, I am using a rather kludgy work around, ala: $a = "row[4].gndbus"; $b = "row[4]"; $b =~ s/([\.\[\]\(\)])/\\\1/g; if( $a =~ /$b/) { ... } This seems to work, but it (1) changes $b, and (2) is fairly clumsy. I'm looking for better solutions! Something elegent would be nice, such as: if( $a =~ /$b/l) { ... } where the "l" operator would denote that $b should be taken as a literal (assume meta characters are literal instead, equiv. to \x). Isn't this kind of what the "e" operator does for substitute? Perl didn't like it when I tried it here! So throw me some ideas, I'm all ears! -- Disclaimer: All spelling and/or grammar in this document are guaranteed to be correct; any exseptions is the is wurk uv intter-net deemuns,. Mike McManus Mike.McManus@FtCollins.NCR.COM, or NCR Microelectronics ncr-mpd!mikemc@ncr-sd.sandiego.ncr.com, or 2001 Danfield Ct. uunet!ncrlnk!ncr-mpd!garage!mikemc Ft. Collins, Colorado (303) 223-5100 Ext. 378