语法错误的问题,请大侠们指点,谢谢!!!

语法错误的问题,请大侠们指点,谢谢!!!

语法错误的问题,请大侠们指点,谢谢!!!
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.

不知道这个错误指什么,还望高手指点,不胜感谢!!!




   

语法错误,一般是原因有2点
1. 左右括号不匹配 {} () ,
2. 缺少 ;
仔细检查47 和70行前后是否有这种情况
试过用下面的代码检测红色.
试过用下面的代码检测红色那行代码是否正确:
#!/usr/bin/perl -w

print "Please enter the path of the output file:";
$output=<STDIN>;
chomp $output;
open (OUTPUT, ">$output")||die "Cannot open the file:$!";
@RT_sorted=(1, 2, 3, 4, 5);
for ($i=0; $i<@RT_sorted-1; $i++)
[color=red]{print OUTPUT "Segment", "\n", "\t", "General", "\n", "\t\t\t", "End", "\t", "$RT_sorted[$i + 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]
close (OUTPUT);

输出到OUTPUT的语句和第一次的代码一样(红色标记),不同的是第一次的代码中,print语句是在if的语句块中,先判断条件在执行写入;而在测试代码中,print语句是直接在for循环的语句块中,没有判断条件。执行的时候测试语句没有问题,输出如预料的一样,如下:
Segment
General
End 2
General End

MS(n)
Auto MS(n)
include/exclude list
Segment
General
End 3
General End

MS(n)
Auto MS(n)
include/exclude list
Segment
General
End 4
General End

MS(n)
Auto MS(n)
include/exclude list
Segment
General
End 5
General End

MS(n)
Auto MS(n)
include/exclude list

说明这个print语句应该没有,但是在第一次代码运行时提示
syntax error at Yeast_MS_Mass_RT.pl line 47, near ")
{"
syntax error at Yeast_MS_Mass_RT.pl line 70, near ")
{"
不知道问题出在哪儿?迷惑。。。。。。。。。。。。还请高手帮忙看看!
if (defined($Time.
if (defined($Timesegment_mass[0])
ok.谢谢anthony兄![CCB]1.
ok.谢谢anthony兄![CCB]12[/CCB]