my $cmd = 'this is a "testin$g" ok';
print Dumper($cmd);
$VAR1 = 'これは "testin$g" OK';
my $cmd = 'this is a "testin$g" ok';
$cmd =~ s/\$/\\\$/;
print Dumper($cmd);
$VAR1 = 'これは "testin\\$g" でOK';
「これは "testin\$g" OK」のような文字列にしようとしています。$ の前の単一の \。しかし、$ を \$ に置き換えても、代わりに 2 になります。