[EMAIL PROTECTED] wrote:

> In a message dated 8/21/2006 5:48:44 A.M. Eastern Standard Time,
> [EMAIL PROTECTED] writes:
>  
>> <part of html code><a href=oper>Operation</a>
>>   >> <a href=oper?detail=31 title="ID = 31"
>> >OMnMusi y~</a><h2> OMnMusi
> y~</h2>_JPHo1d77b0!D$MwxhzXL$WQZ2bFX!M3dbzjiDYROglF_w9sKr4cPSPvCYEDv5ElZ56S0EMJ_$LHHzuxKvYrJnzRLwrxRiiRukNu
>> </part of html code>here is part of the perl code :$title = "OMnMusi
> y~";$content =
> "_JPHo1d77b0!D$MwxhzXL$WQZ2bFX!M3dbzjiDYROglF_w9sKr4cPSPvCYEDv5ElZ56S0EMJ_$LHHzuxKvYrJnzRLwrxRiiRukNu";
>> I wanna use ~m#<a
> href=oper?(detail=(.*?)\stitle="ID\s=\s(.*?)")>($title)</a>\n<h2>\s($title)</h2>\n($content)\n<h3>#gto
> match it to check if the HTML works right.
>> but "$","&","*",etc will be translated into part of the regex.This is
> really a trouble.I wanna use ~s///g   to add a "\" before those
> charactor.But it seems don't work.
>> Could anyone help?Thanks a lot~!
>>
>  
> try using  quotemeta()  function:  
>  
> perldoc -f quotemeta
>  
>     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
>             function implementing the "\Q" escape in double-quoted strings.
>  
>             If EXPR is omitted, uses $_.
>  
> C:[EMAIL PROTECTED]>perl -we "use strict;   my $hasmeta = 'a$b*c+d?e\f^';
> my $nometa = quotemeta $hasmeta;
> print $nometa;"
> a\$b\*c\+d\?e\\f\^

Or do it in the vrbl itself (using ' as delim will also turn of interpolation 
of $/@):
        my $title = qr'OMnMusiy~';
        my $content = 
qr'_JPHo1d77b0!D$MwxhzXL$WQZ2bFX!M3dbzj0EMJ_$LHHzuxKvukNu';

Or you can use \Q .. \E inside the RE around the vrbl refs:
        m#<a 
href=oper?(detail=(.*?)\stitle="ID\s=\s(.*?)")>(\Q$title\E)</a>\n<h2>\s(\Q$title\E)</h2>\n(\Q$content\E)\n<h3>#gto;

PS:  Posting the original post in plain text ISO-8859-1 will usually get better 
results.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to