我必须GetOptions
在哈希数组中使用.
我的要求是编写一个包含多个选项组合的Perl脚本,例如:
test.pl -a mango -s ripe -d <date value>
Run Code Online (Sandbox Code Playgroud)
要么
test.pl -a apple -s sour
Run Code Online (Sandbox Code Playgroud)
其中mango
,ripe
,apple
,sour
,等是用户输入,其还用于存储在可变绑定SQL在WHERE
一个条款SELECT
查询来生成报告.
我这个代码
use vars qw ($opt_a $opt_s $opt_d)
Getopts('a:s:d:')
Run Code Online (Sandbox Code Playgroud)
现在我在编写hash方面遇到了一个问题
my %hash = @ARGV
Run Code Online (Sandbox Code Playgroud)
上面的哈希定义是正确的吗?有没有更好的方法来使用哈希?
perl ×1