Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!uvaarpa!mmdf From: eichin@apollo.com (Mark Eichin) Newsgroups: comp.lang.perl Subject: shouldn't backslash really quote? Message-ID: <1991May22.175723.18174@uvaarpa.Virginia.EDU> Date: 22 May 91 17:57:23 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: eichin@apollo.com Organization: The Internet Lines: 37 The script (at the end of this message) prints: Line == <> found x-pat found x-brace-dollar-pat I would have expected it to print "found x-slash-dollar-pat" as well, or at least threeslash... I get this output with VAX/BSD perl 3.041 and 4.000, as well as Apollo Domain/OS perl 4.003. (I really do want pattern matching, not equality checking, and (as the last if clause shows) I should really be able to do this without eval.) Can anyone explain to me why I can't simply backslash a dollar sign, as is implied by the info file, "Simply quote all the non-alphanumeric characters: $pattern =~ s/(\W)/\\$1/g;" #!perl $_='x_$foo'; $pat = "foo"; print "Line == <<$_>>\n"; if(/x_.$pat/) { print "found x-pat\n"; } if(/x_\$$pat/) { print "found x-slash-dollar-pat\n"; } if(/x_\\$$pat/) { print "found x-twoslash-dollar-pat\n"; } if(/x_\\\$$pat/) { print "found x-threeslash-dollar-pat\n"; } if(/x_[\$]$pat/) { print "found x-brace-dollar-pat\n"; } _Mark_ CCD-East