【发布时间】:2009-05-28 14:22:52
【问题描述】:
这是我编写的用于测试命令行参数处理的简单脚本:
use Getopt::Long;
my $help = 0;
GetOptions(
'help|h|?' => \$help,
) or die "Error!";
print "OK\n";
我得到的结果如下:
D:\>perl test.pl --help
OK
D:\>perl test.pl --hell
Unknown option: hell
Error! at test.pl line 10.
D:\>perl test.pl --he
OK
D:\>perl test.pl --hel
OK
以前有人注意到这一点吗?行为(接受 he 和 hel 而不是帮助)是潜在的错误吗?
【问题讨论】: