我Getpt::Long
用来从命令行获取参数并将它们分配给它们各自的变量。但是,我在打印时遇到错误。代码和错误如下:
#!usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
GetOptions(
"mount_path=s" => \my $old_path,
"var=s" => \my $var,
"log_path=s" => \my $log_path,
) or die "Error in input variables\n";
print <<"END_INPUTS";
These are your inputs:
old_path= $old_path
var = $var
log_path=$log_path
Press enter twice if all looks GOOD
*********************************************************
END_INPUTS
命令行参数如下:
perl getvar.pl --mount_path=/var/sslvpn --var=7.0.0.2_va-SSLVPN-!7.0.0.2.16sv+.jpn-05!j+g_554863- --log_path=log.txt
运行此程序时出现以下错误
-bash: !7: event not found