솔루션을 찾기 위해 몇 가지 토론을했지만 그 중 아무 것도 내 경우에는 작동하지 않는 것 같습니다.글로벌 심볼 정의 (오류)
나는
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) {
.
.
.
}
이 오류 코드의 다음 조각을 얻을 수있다 : 전역 기호 "$ DirA는"
사람이 좀 도와 주시겠습니까 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