Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!wuarchive!emory!hubcap!ncrcae!ncrlnk!ncr-mpd!Mike.McManus From: Mike.McManus@FtCollins.NCR.com (Mike McManus) Newsgroups: comp.lang.perl Subject: Parens in a reg exp Message-ID: Date: 12 Sep 90 08:16:52 GMT Sender: uucp@ncr-mpd.FtCollins Distribution: comp Organization: NCR Microelectronic Products, Ft. Collins, CO Lines: 46 I'm reading tokens in from a file and doing compares on the token, sort of like: @toklist = ("VDD", "GND", IN", "OUT", "INOUT"); while(<>) { if( do IS_TERM()) { ... } } sub IS_TERM() { $token = (split)[1]; if( join( " ", @tklist) !~ /$token/) {return(0);} foreach $i (@toklist) { if( $i eq $token) { .... return(1); } } return(0); } # Warning! Not the REAL perl code, but a resonable facsimile thereof... 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. NOTE: I use the 'if(join...) return 0' as a quick and dirty check, before launching into a 'foreach $i (@toklist)', so as to save time. Will it, can forget about it. This would solve my problem, too. Thanks! -- 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