P is for Practical | |
PerlMonks |
Re: How do I process many (conflicting) command line parameters?by Discipulus (Canon) |
on Jun 30, 2017 at 01:19 UTC ( [id://1193878]=note: print w/replies, xml ) | Need Help?? |
hello ozboomer, interesting question. For the basic approach i totally agree with above Anonymous Monk. Me too I ussume you are using Getopt::Long module with all it's features. More: if I erase some value fidded by command line and the application is somehow risky I'd print th to the screen the resulting command line arg line and I'd ask for confirmation. Having excluding parameters can be complex and I saw not a lot of examples of managing it. What I can imagine for a very big number of, potentially, mutually exclusive parameters can be similar to an dispatch table. You can associate references to all variables you assigned via Getopt::Long to some code to be run. Better: you can use an array for the dispatch table, processing rules from 0 to the last one and doing so giving priority to more important arguments. Let's say you have --chars num that sets $chars and also --display name that that sets $display{name} If $display{name} is tv you want to assign a different value to $chars and clean the --monochromo $bw switch
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
|
|