in reply to Re: Re: $ variables in command line
in thread $ variables in command line

You're asking for it to interpolate $1 in $r when you use double-quotes. Don't do this. $1 is undef when you do that, so of course, $r ends up being " world".

Here's a really crazy example of how to do what you want.
$test = "hello"; $s = "(hello)"; $r = '"$1 world"'; $test =~ s/$s/eval $r/e; print $test;
Note that this uses eval, which isn't everyone's thing.