Think about Loose Coupling | |
PerlMonks |
Re: Getopt - Validate arguments before processing -- BEGINby Discipulus (Canon) |
on Jan 31, 2022 at 08:57 UTC ( [id://11140986]=note: print w/replies, xml ) | Need Help?? |
Hello g_speran, interesting question: I was sure Getopt::Long was consuming the @ARGV array so you had the possibility to check if something unkonow is still there.. but is too late for this when it arrives the moment and "Processing sub first" is already fired. Then I read about die("!FINISH") special behaviour, but is not useful.. again it fires too late.. so you must move quick to intercept the unkonown option. A BEGIN block does the trick (but I moved the help sub on top, so it is parsed before the BEGIN block, so it can be called: you must move other subs to give them a chance to be called):
L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|