我是PERL的初学者,负责解决上述问题。所以我得到这个错误 splice()偏移过去的数组的末尾,我用过严格后;如何在用户指定的位置切换两个底座
我花了几个小时修改代码,但无济于事所以会有人请向我解释为什么它不为外行地(我是一个新手总)
谢谢合作!
#!usr/bin/perl
use strict;
use warnings;
#Ask for input from user
#Then switch two bases at positions specified by the user
print "Enter your DNA string:\n";
my @input_seq = split(//, <STDIN>);
chomp @input_seq;
print "First base: "; #position of first base
my $base_1_pos = <STDIN>;
chomp $base_1_pos;
my $base_1 = "$input_seq[$base_1_pos]";
print "Second base "; #position of second base
my $base_2_pos = <STDIN>;
chomp $base_2_pos;
my $base_2 = "$input_seq[$base_2_pos]";
@input_seq = splice(@input_seq, "$base_1_pos", 1, "$base_2"); #splice $base_2 into $base_1
@input_seq = splice(@input_seq, "$base_2_pos", 1, "$base_1"); #splice $base_1 into $base_2
print "@input_seq\n\n"; #print output
最良好的祝愿, 卫
您能否提供示例输入来演示该问题? – choroba 2014-09-26 16:38:47