下面给出的脚本在每次出现“E”时剪切输入字符串并将其存储在一个数组中。最终输出显示“E”的每个位置的所有碎片字符串。但问题是,这个脚本在输出的数组的最后一个元素中没有显示任何“E”,它只显示到“D”。我得到的输出是-
ABCDEABCDE ABCDE ABCDE ABCD
ABCDE ABCDEABCDE ABCDE ABCD
ABCDE ABCDE ABCDEABCDE ABCD
ABCDE ABCDE ABCDE ABCDEABCD
ABCDE ABCDE ABCDE ABCDE ABCD
但我想要的最终输出是 -
ABCDEABCDE ABCDE ABCDE ABCDE
ABCDE ABCDEABCDE ABCDE ABCDE
ABCDE ABCDE ABCDEABCDE ABCDE
ABCDE ABCDE ABCDE ABCDEABCDE
ABCDE ABCDE ABCDE ABCDE ABCDE
我的剧本是——
my $s = 'ABCDEABCDEABCDEABCDEABCDE';
if (substr($s,-1) eq "E") {
@array1 = @array[0 .. $#array-1];
print "Results of 1-missed cleavage having 1E at the end\n\n";
for my $array1 (@array1) {
substr($s, $array1-1, 1) = "\0";
my @a = split(/E(?!P)/, $s);
substr($s, $array1-1, 1) = 'E';
$_ =~ s/\0/E/g foreach (@a);
$result = join ("E,", @a);
@final = split(/,/, $result);
print "@final\n";
}
my @output=split(/E(?!P)/, $s);
$out = join ("E,", @output);
@output1 = split(/,/, $out);
print "@output1\n\n";
}
else {
print "E is not at terminal position"
};