语法错误的问题,请大侠们指点,谢谢!!!
1 代码如下:
#!/usr/bin/perl -w
print "Please enter the path of the mass_retention-time file:";
$mass_retention_time=<STDIN>;
chomp $mass_retention_time;
print "Please enter the path of the output file:";
$output=<STDIN>;
chomp $output;
open (RAWDATA, "$mass_retention_time")||die "Cannot open the file:$!";
open (OUTPUT, ">$output")||die "Cannot open the file:$!";
@mass_retention_time=<RAWDATA>;
$i=0;
foreach $mass_r_t (@mass_retention_time)
{if ($mass_r_t=~/\t(\d+\.\d+)\t(\d+\.\d+)\n/)
{$RT[$i]=$1;$RT[$i + 1]=$2;
$i=$i + 2;}
}
%hash1=();
foreach $RT_1 (@RT)
{$hash1{$RT_1}=1;}
@RT_1=keys %hash1;
@RT_sorted=sort {$a<=>$b} @RT_1;
print OUTPUT "Segment", "\n", "\t", "General", "\n", "\t\t\t", "End", "\t", "$RT_sorted[0]", "\n", "\t", "General End", "\n", "Segment End", "\n\n";
for ($j=0; $j<@RT_sorted - 1; $j++)
{$k=0;
if ($j<@RT_sorted - 2)
{foreach $mass_R_T (@mass_retention_time)
{if ($mass_R_T=~/^(\d+\.\d+)\t(\d+\.\d+)\t(\d+\.\d+)\n/)
{$mass=$1;$RT_start=$2;$RT_end=$3;
if ($RT_end>$RT_sorted[$j] and $RT_start<$RT_sorted[$j + 1])
{$Timesegment_mass[$k]=$mass;
$k=$k + 1;}
}
}
}
elsif ($j=@RT_sorted - 2)
{foreach $mass_R_T (@mass_retention_time)
{if ($mass_R_T=~/^(\d+\.\d+)\t(\d+\.\d+)\t(\d+\.\d+)\n/)
{$mass=$1;$RT_start=$2;$RT_end=$3;
if ($RT_end>$RT_sorted[$j] and $RT_end<$RT_sorted[$j + 1])
{$Timesegment_mass[$k]=$mass;
$k=$k + 1;}
}
}
}
if (defined($Timesegment_mass[0])
[color=red]{print OUTPUT "Segment", "\n", "\t", "General", "\n", "\t\t\t", "End", "\t", "$RT_sorted[$j + 1]", "\n", "\t", "General End", "\n\n", "\t", "MS(n)", "\n", "\t\t", "Auto MS(n)", "\n", "\t\t\t", "include/exclude list", "\n", "\t\t\t\t";[color=black]
@Timesegment_mass_sorted=sort {$a<=>$b} @Timesegment_mass;
while (defined($Timesegment_mass_sorted[0]))
{if (!defined($Timesegment_mass_sorted[1]))
{print OUTPUT "$Timesegment_mass_sorted[0] - 0.5", "\t", "$Timesegment_mass_sorted[0] + 0.5", "\n";}
elsif (defined($Timesegment_mass_sorted[1]))
{$array_mass[0]=$Timesegment_mass_sorted[0];
$m=1;
while ($Timesegment_mass_sorted[1]<=$Timesegment_mass_sorted[0] + 1)
{$array_mass[$m]=$Timesegment_mass_sorted[1];
$m=$m + 1;
splice (@Timesegment_mass_sorted, 1, 1);
}
if (@array_mass==1)
{print OUTPUT "$array_mass[0] - 0.5", "\t", "$array_mass[0] + 0.5", "\n";}
elsif (@array_mass>1)
{print OUTPUT "$array_mass[0] - 0.5", "\t", "$array_mass[@array_mass] + 0.5", "\n";}
}
splice (@Timesegment_mass_sorted, 0, 1);
}
print OUTPUT "\t\t\t", "include/exclude list end", "\n", "\t\t", "Auto MS(n) End", "\n", "\t", "MS(n) End", "\n", "Segment End", "\n\n";
}
if (!defined($Timesegment_mass[0])
[color=red]{print OUTPUT "Segment", "\n", "\t", "General", "\n", "\t\t\t", "End", "\t", "$RT_sorted[$j + 1]", "\n", "\t", "General End", "\n", "Segment End", "\n\n";}[color=black]
}
close(RAWDATA);
close(OUTPUT);
运行是报错,提示语法错误,如下:
J:\perl>perl Yeast_MS_Mass_RT.pl
syntax error at Yeast_MS_Mass_RT.pl line 47, near ")
{"
syntax error at Yeast_MS_Mass_RT.pl line 70, near ")
{"
Execution of Yeast_MS_Mass_RT.pl aborted due to compilation errors.
不知道这个错误指什么,还望高手指点,不胜感谢!!!