That won't work, since you didn't escape $search or $replace. Also, you're needlessly recompiling $search if it's already compiled. Use the following instead:
$escaped_replace = '$1 (\$1.00)'; # Escape \, $, @ and / eval "\$title =~ s/\$search/$escaped_replace/";
But since the only thing that needs to be compiled is the replace expression (not the entire substitution), the following is even better:
$quoted_replace = '"$1 (\$1.00)"'; # Escape \, $, @ and /. Add quotes $title =~ s/$search/eval $quoted_replace/e;
Of course, not using eval EXPR would be even better. In other words, a templating system would be even better. I mentioned this and posted an example in the thread to which I linked in my other post.
Update: Added "or $replace".
Update: Oops, davidrw is correct. $search doesn't need escaping.
In reply to Re^2: Variable substitute and capturing
by ikegami
in thread Variable substitute and capturing
by Brutha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |