我在 perl 方面没有经验,我很难解决这个错误。任何帮助表示赞赏。脚本如下(第40行报告的问题,粗体):
#! /usr/bin/perl
print "Please enter filename (without extension): ";
$input = <>;
chomp ($input);
print "Please enter total no. of sequence in fasta file: ";
$orig_size= <>*2-1;
chomp ($orig_size);
open (INFILE, "$input.fasta") or die "Error opening input file for shuffling!";
open (SHUFFLED, ">"."$input"."_shuffled.fasta") or die "Error creating shuffled output file!";
@array = (0); # Need to initialise 1st element in array1&2 for the shift function
@array2 = (0);
$i = 1;
$index = 0;
$index2 = 0;
while (my @line=<INFILE>){
while ($i<=$orig_size) {
$array[$i] = $line[$index];
$array[$i]=~ s/(.)\s/$1/seg;
$index++;
$array2[$i] = $line[$index];
$array2[$i]=~ s/(.)\s/$1/seg;
$i++;
$index++;
}
}
my $array = shift (@array);
**my $array2 = shift (@array2);**
for ($i = $header_size; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@array[$i,$j] = @array[$j,$i];
@array2[$i,$j] = @array2[$j,$i];
}
while ($index2<=$header_size) {
print SHUFFLED "$array[$index2]\n";
print SHUFFLED "$array2[$index2]\n";
$index2++;
}
close(INFILE);
close(SHUFFLED);