$data=~s#$r#$s#
How about
$data=~s#$r#$s#e [download]
In reply to Re: reinterpolation of regexp (and strings?) by rovf in thread reinterpolation of regexp (and strings?) by AlwaysLearning