I went through a couple of discussions to find the solution but none of them seem to be working in my case.
I have the following piece of code
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) {
.
.
.
}
I get this error: Global symbol "$DirA" requires explicit package name at test_switch.tc
Can someone please help me with the same. My intension is to add options/switches to my script.. Like "test.pl -A", "test.pl -B" for which I started with a case stmt. Please provide inputs on this.