运行Perl脚本时出现以下错误:
无效范围“B->”在音译操作员./foo.pl第249行
但是,第249行被注释掉了,我在代码中的任何地方都没有使用音译操作符tr
。
这是我脚本的相关部分。第249行是# foreach (@projects)
,如您所见,它已被注释掉。
# Find the project name, hardware, and version from the archive given
$project = undef;
$hardware = undef;
$version = undef;
if (defined $testfarmDB){
my $idFile = `pwd`;
chomp $idFile;
$idFile .= "/$ENV{TESTDIR}/testrun.id";
y @filecontent = `cat $idFile`;
$filecontent[0] =~ /(\d+)/;
my $testRunID = $1;
$hardware = $testfarmDB->getTestRunModelName($testRunID);
$project = $testfarmDB->getTestRunProjectName2($testRunID);
$version = $testfarmDB->getTestRunSWRevisionName($testRunID);
}else{
die "Cannot connect to Database. Program terminated. \n";
}
print " Project = $project\n";
print " Model Type = $hardware\n";
print " Software Version = $version\n";
# Break up the path given to determine the project and version number
# foreach (@projects)
# {
# if ($archive =~ /($_)/i)
# {
# $project = $_;
# foreach my $hw (@hardwares)
# {
# if ($archive =~ /$hw/i)
# {
# $hardware = $hw;
# last;
# }
# }
# last;
# }
# }
$archive =~ /((?:\d+\.)+\w+)/;
# $version = $1;
我该如何解决这个问题?
答案 0 :(得分:7)
此:
y @filecontent = `cat $idFile`;
y
是tr
运算符的古老同义词。 Perl正在搜索另外两个@
字符来完成y@...@...@
语句,并在评论部分找到第二个字符。