Hi!

I'm making a text replace and my text to search includes a metacharacter (.
The text to be searched has been stored in a scalar for example $search. 
The text where the search will be made has been stored for example in a scalar 
$text. Here is what I'm doing:

$search = "for example (this)";
$text = "looking for example (this)";
$toBeReplaced = "that";

$text =~ s|$search|$toBeReplaced|;

That doesn't work, if you make it this way:

$text =~ s|for example \(this\)|$toBeReplaced|;

works fine, but how can I backslash the metacharacters in a scalar?

Petri Rautakoski


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to