我有以下一段代码
my $use = "Use: " . basename($0) . " [options]";
my $version = "Version: 0.1 \n";
my $variableA;
my $variableB;
GetOptions(
'a=s' => \$variableA,
'help' => sub { print $use; exit 0 },
'version' => sub { print $version; exit 0 },
'b' => sub { \$variableB, &this_subroutine; goto NOWGOHERE; },
);
die "Incorrect use. \n" unless (defined $variableA || defined $variableB);
sub this_subroutine {
print "$variableB\n";
}
NOWGOHERE: print "HELLO I'M NOW HERE\n";
我想要做的是设置$variableB
然后执行&this_subroutine
and thegoto NOWGOHERE
但我只能让它做一个或另一个,而不是两者,使用一个'b=s' => \$variableB,
或sub { &this_subroutine; goto NOWGOHERE;0 },
尝试同时执行这两种操作时,我似乎无法打印$variableB
,是否有明显的我遗漏或在语法上做错了什么?
使用'b=s' => \$variableB, sub { &this_subroutine; goto NOWGOHERE; },
似乎也不起作用?
非常感谢您的帮助,非常感谢