I have this getopt:
GetOptions( GetOptions ("library=s" => \@libfiles);
@libfiles = split(/,/,join(',',@libfiles));
"help" => \$help,
"input=s" => \$fileordir,
"pretty-xml:4" => \$pretty
);
Is it possible for Getopt::Long::GetOptions to detect if the same option is provided on the command line multiple times? For example, I would like the following to generate an error:
perl script.pl --input=something --input=something
Thanks
I don’t think there is direct way but you have two options:
Use an array and check after processing the options
Use a subroutine and check if the option is already defined
In this case you can use an exclamation mark
!at the beginning of thedieand the error will be catched and reported as a usual Getopt error (see the documentation of Getopt::Long for the details)