The (...) is being interpreted as a regular expression group. Try:
$inputstring=~s/\Q$t/$r/;
The \Q quotes any special characters following it so they lose their special meaning, so your $t will be matched literally.
For details see quotemeta and perlre.
In reply to Re: replace not working as expected
by Anonymous Monk
in thread replace not working as expected
by digirent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |