in reply to Re: Getopt - Validate arguments before processing -- BEGIN
in thread Getopt - Validate arguments before processing
which means, as Corion already mentioned, you have to move the BEGIN block below the subroutines, which defeats the purpose.Undefined subroutine &main::first called at .../Getopt/Long.pm line 60 +7. Available options are: --first --help Invalid options passed to ....pl BEGIN failed--compilation aborted at ....pl line 17.
besides, from an esthetic viewpoint, it isn't nice, if a program reacts with a "compilation error" to a wrong invocation.
I think I like haukex's variant "push @actions" best, and it would even allow for an optional --ignore-unknown-switches or --please-dont-die switch to suppress dying on invalid options ;-)
|
|---|