Your stated requirements have problems:
-
In isolation, this is pretty straightforward.
The following would need some additional "checking" code, but the guts of it are:
$ perl -E '
my $str = "sssDDDsssDDDssUss";
my ($fore, $aft) = split /U/, $str, 2;
$fore =~ s/s/i/g;
$aft =~ s/s/o/g;
say "$str\n", join "U", $fore, $aft;
'
sssDDDsssDDDssUss
iiiDDDiiiDDDiiUoo
-
This makes no sense as there are no more 's' characters left to modify.
If there's some typo in what you wrote, then perhaps something similar to the code in my last point would suffice.
-
This is easily achieved with transliteration:
$ perl -E '
my $str = "sssDDDsssDDDssUss";
say $str;
$str =~ y/DU/M/;
say $str;
'
sssDDDsssDDDssUss
sssMMMsssMMMssMss
-
You didn't finish writing this point: "... then all s becomes".
You'll need to tell us what you intended to write after "becomes".
Some other points:
-
Your input data is far too long.
The same information could have been conveyed with strings of less than a dozen characters.
-
You don't tell us what output you expected.
-
You don't tell us what output you got from your posted code.
-
Please do not italicise your code.
It's harder to read; in particular, backslashes (\) can look like pipes (|).
-
Your input looks like FASTA format.
If you need it, there's plenty of examples of parsing that format on this site.