为什么即使 `tr` 没有出现在我的代码中,我也会收到错误 'Invalid range " B->" in transliteration operator'?

Why do I get the error 'Invalid range " B->" in transliteration operator' even though `tr` doesn't appear in my code?

我在 运行 我的 Perl 脚本时遇到以下错误:

Invalid range "B->" in transliteration operator at ./foo.pl line 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 = ;
    $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 = ;

我该如何解决这个问题?

这个:

 y @filecontent = `cat $idFile`;

ytr 运算符的古老同义词。 Perl 正在搜索另外两个 @ 个字符来完成 y@...@...@ 语句,它在您的评论部分找到了第二个字符。