digirent has asked for the wisdom of the Perl Monks concerning the following question:
But it isn't changed. When I remove the ( and ) the replacement works well, but I've no influence on the inputstring. So what I want to achive is that $t is handled as a "exact search string" and not as a to be interpreted regular expression. Help is very appreciated.#!/usr/bin/perl $inputstring=qq{startstring <strong>(substring)</strong> endstring}; $t=qq{<strong>(substring)</strong>}; $r=qq{<b>(substring)</b>}; $inputstring=~s/$t/$r/; print $inputstring; #The final string should be: startstring<b>(substring)</b> endstring
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replace not working as expected
by toolic (Bishop) on Feb 04, 2014 at 19:26 UTC | |
|
Re: replace not working as expected
by Anonymous Monk on Feb 04, 2014 at 19:32 UTC |