Since you are dealing with single characters, tr /// is the obvious answer:
tr/~x/-~/;
However, you will need s /// to handle longer sequences:
my %subs = ( '~' => '-', 'x' => '~' );
my $pat = join '|', map quotemeta, keys %subs;
s/($pat)/$subs{$1}/g;
source
share