On Wed, Jun 20, 2001 at 03:46:31AM -0500, Bob Tanner wrote:
> Quoting Thomas Eibner (thomas at stderr.net):
> > On Wed, Jun 20, 2001 at 03:26:52AM -0500, Bob Tanner wrote:
> > > Quoting Bob Tanner (tanner at real-time.com):
> > > > I want to do a substitution like this:
> > > > 
> > > > s/#4/Blah hash $288/gi
> > > 
> > > I guess a better question what is a quick and easy was to escape all
> > > meta-characters in a string?
> > > 
> > > Like, if I want to escape * ? $ 
> > 
> > perldoc -f quotemeta
> > 
> 
> perldoc -f quotameta
                 ^ 
quotEmeta ;-)

> No documentation for perl function `quotameta' found

       quotemeta EXPR
       quotemeta
               Returns the value of EXPR with all non-"word"
               characters backslashed.  (That is, all characters
               not matching "/[A-Za-z_0-9]/" will be preceded by
               a backslash in the returned string, regardless of
               any locale settings.)  This is the internal func-
               tion implementing the "\Q" escape in double-quoted
               strings.

               If EXPR is omitted, uses "$_".

$ perl
$test = quotemeta '*?$-';
print $test, "\n";^D
\*\?\$\-

-- 
  Thomas Eibner <http://thomas.eibner.dk/> DnsZone <http://dnszone.org/>
  mod_pointer <http://stderr.net/mod_pointer>