A. Pagaltzis wrote:
* Johan Vromans <[EMAIL PROTECTED]> [2005-06-17 17:20]:

I can make this information available, if users would be
interested.


Access to structured data is always nicer than implementing and
re-implemeting a parser for its serialized form.

So if it doesn’t take too much effort, it would be nice to have.
I might even need this at some point  [...]

Being in the middle of writting option processing code[1] I'd like to throw a few ideas and comments out into the void...

First, order of commandline arguments does matter. The code I'm writting depends on this in several ways. First, it reads options from a rcfile much like the format used for svn, cvs, etc.

~/.modulebuildrc
* --verbose
install --uninst --noverbose

Command line options are parsed (passed thru to G::Long). Unless an option is present to disable rcfile processing, we process the rcfile. In the rcfile we have global options ('*'), and action specific options. When processing the rcfile we pass in to G::Long the options in a specific order: @global_rc_options, @action_specific_rc_options, @commandline_options. Notice in the example that globally the option --verbose is passed in, then only when executing the 'install' action verbosity is turned off. Finally, the commandline can be used to override any of these. If order didn't matter, there would be no way to override the defaults from the rcfile.

Another case is setting include directories. We want include directories searched in the order they appear on the commandline ('include-dirs=s@')

./Build --include-dirs /special/place --include-dirs /usr/include

A different order would cause problems if two different headers with the same name happen to exist in both locations.


I do wish Getopt::Long provided for more custom processing by providing incremental parsing: while ( $parser->next ) {...}. I also wish it accepted a string or argv like array and only used @ARGV as a default (and passed a reference to the option array to custom subs). Also, it'd be a bit more OO to provide the option to store parsed options internally, instead of storing the results in external variables.

I think there were more things I wished for when writing that module, but I'm too tired to think what they were right now.

Randy.

1. <http://thepierianspring.org/perl/Scratchpad.zip>

Reply via email to