我经历了几次讨论以找到解决方案,但似乎没有一个人在我的情况下工作。定义全局符号(错误)
我有以下的代码
print ("Choose from the following\n");
print ("op1 op2\n");
my $x = <>;
chomp($x);
print ("x is $x");
if ($x eq "op1")
{
my $DirA = "./A";
my $DirB = "./B"; # **I want to use this dirA and dir B below (Tried switch stmts but I
#**get the same error)**
}
opendir my($dh), "$DirA" or die "Couldn't open dir DirA!";
my @files = readdir $dh;
closedir $dh;
system("rm -rf diffs");
system ("mkdir diffs\n");
foreach my $input (@list) {
.
.
.
}
我得到这个错误:全局符号“$迪拉”要求在test_switch.tc明确包名
是否有人可以帮助我的相同。我的意图是将选项/开关添加到我的脚本中。像“test.pl -A”,“test.pl -B”,我开始使用case stmt。请就此提供意见。
你可以使用perl模块吗?如果是这样,我建议你考虑使用[Getopt :: Long](http://search.cpan.org/~jv/Getopt-Long-2.39/lib/Getopt/Long.pm)。它会让你的生活变得更轻松。 – David 2013-04-10 00:17:20