Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Perl's GetOpt::Long accepting abbreviations of switches a bug?

Tags:

perl

getopt

This is a simple script I have written to test command line argument handling:

use Getopt::Long;

my $help = 0;

GetOptions(
'help|h|?' => \$help,
) or die "Error!";

print "OK\n";

The results I got are as follows:

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

Has anybody noticed this before? Is the behaviour (accepting he and hel instead of help) a potential bug?

like image 866
Andy Avatar asked Nov 28 '22 12:11

Andy


1 Answers

it is a feature documented here

like image 191
dfa Avatar answered Dec 19 '22 23:12

dfa