Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于提取某个子字符串的Perl索引函数_Perl - Fatal编程技术网

用于提取某个子字符串的Perl索引函数

用于提取某个子字符串的Perl索引函数,perl,Perl,给定存储在数组中的某个序列a,我必须找出较大的序列B是否包含序列a 我被困在索引部分。。。我得到一个错误,参数“TGACCA”在第69行的数组元素中不是数字,这是: if(索引($record_r1[1],$r2_seq[$check])!=-1) 代码是: foreach my $check (@r2_seq) { if (index($record_r1[1], $r2_seq[$check]) != -1) { $matches= $matches + 1;

给定存储在数组中的某个序列a,我必须找出较大的序列B是否包含序列a

我被困在索引部分。。。我得到一个错误,参数“TGACCA”在第69行的数组元素中不是数字,这是:

if(索引($record_r1[1],$r2_seq[$check])!=-1)


代码是:

foreach my $check (@r2_seq)
{
  if (index($record_r1[1], $r2_seq[$check]) != -1)
  {
     $matches= $matches + 1;
     print "Matched";
  }
  else
  {
  }
}
$check
接受
@r2\seq
中每个元素的值。它不是索引

$r2_seq[$check]
这正试图使用
@r2_seq
元素作为
@r2_seq
的索引。这不可能是你想要的。更可能的情况是,您希望使用

$check

$check
接受
@r2\seq
中每个元素的值。它不是索引

$r2_seq[$check]
这正试图使用
@r2_seq
元素作为
@r2_seq
的索引。这不可能是你想要的。更可能的情况是,您希望使用

$check


.

我相信您希望
$check
成为索引,因此请使用以下代码:

foreach my $index (0..$#r2_seq)
{
  if (index($record_r1[1], $r2_seq[$index]) != -1)
  {
     $matches= $matches + 1;
     print "Matched";
  }
  else
  {
  }
}

我相信您希望
$check
成为索引,因此请使用以下代码:

foreach my $index (0..$#r2_seq)
{
  if (index($record_r1[1], $r2_seq[$index]) != -1)
  {
     $matches= $matches + 1;
     print "Matched";
  }
  else
  {
  }
}

即使子字符串在那里,它也不会去比赛。即使子字符串在那里,它也不会去比赛。