on-internet
← Community

Why doesn't getopts('absif:', \%Options) report an error when I pass an invalid option?

Stack Overflow ·

file.pl if (! getopts('abisf:', \%Options)) { # Display usage details print "Usage Error invalid options \n"; exit(1); } If I run: $>perl file.pl -q @argv; This should print the usage error, but it doesn't. $>perl file.pl -a @argv; This should have $Options{a}=1, but what I see is $Options{a}='', i.e., null. What's going on?

Comments

Sign in or sign up to comment and upvote.

No comments yet.