【发布时间】:2018-06-18 10:50:13
【问题描述】:
我收到一个错误,因为全局符号不占用。请帮我解决这个问题。
错误信息:
在字符串中,@@g 现在必须在 gsx.pl 第 5 行“echo Ra@@@g”附近写为 \@g 全局符号“@@g”需要在 ggg.pl 第 5 行显示包名。
use strict;
use warnings;
print "connect to Perforce Server\n";
my $connection=`echo Ra@@@g|p4 -u raj login`;
if ( !$connection ) {
print "Failed to connect to Perforce Server\n";
exit(1);
}
my $status = system("p4 sync");
if ($status == 0) {
my $workon = system("workon demo_project");
my $build = system("gmake –f Makefile bin");
} else {
exit 1;
}
【问题讨论】:
-
你有什么 Perl 版本?在 5.18.2 中,我遇到了完全不同的错误,以及一个很好的警告:
Possible unintended interpolation of @g in string at .... Global symbol "@g" requires explicit package name (did you forget to declare "my @g"?) -
这是为 sun4-solaris 构建的 perl,v5.6.0
-
加入反斜杠
echo Ra@@\@g | p4 -u raj login后现在可以工作了; -
5.6.0 18岁!
-
我已编辑您的代码以修复缩进。不客气,但请以后自己做。明智的缩进是使代码易于理解的最佳方法之一。如果您要让一大群人阅读和理解您的代码,最好让他们尽可能轻松。