perl Getopt::Long madness
- by ennuikiller
The following code works in one script yet in another only works if a specify the "--" end of options flag before specifying an option:
my $opt;
GetOptions(
'help|h' =>
sub { usage("you want help?? hahaha, hopefully your not serious!!"); },
'file|f=s' => \$opt->{FILE},
'report|r' => \$opt->{REPORT},
) or usage("Bad Options");
In other words, the same code words in good.pl and bad.pl like so:
good.pl -f
bad.pl -- -f
If I try
bad.pl -f
I get "unknown option:f"
Anyone have any clue as to what can cause this behavior? Thanks in advnace!