|Welcome to the Monastery|
deriving usage from Getopts::Longby Random_Walk (Prior)
|on Jul 29, 2005 at 11:19 UTC||Need Help??|
Random_Walk has asked for the
wisdom of the Perl Monks concerning the following question:
Great studious and wise monks I am guilty of the sin of typing the same thing into my code more than once.
I feel I must have been negligent in my study of the great cannon of wisdom. My code uses Getopts::Long to set a bunch of switches. When the switches are initialised their use is documented in comments. GetOptions then checks the command line using command line switch names almost the same as the $variable names (easy to make the same). Then I have a usage sub which again lists all these switches and reproduces the same info as the #comments.
A Super Search drowned me in links but did not turn up anything that look relevant.
Is there a simple way to write this information once and have both GetOptions, variable initialisation and the usage sub grab it from the one place ? Is there an existing module ? Do people have their own ad-hoc ways to do this. Should I be thinking POD here ?
Here is an example chunk of code exhibiting this sin. It even exhibits the other problem this causes, available switches do not match usage documentation (slowdown option works but not documented)
Pereant, qui ante nos nostra dixerunt!