Dear all,

Some time ago a proposal was made for a new module, effectively
implementing a Getopt::Long call parsing arguments from a given string
(instead of @ARGV). It was agreed that it would be best to provide
this as an additional entry point in Getopt::Long.

The basic functionality would be something like:

  sub GetoptionsFromString {
    my $string = shift;
    my @opts = @_;
    local @ARGV = shellwords($string);
    GetOptions(@opts);
  }

Trivial, isn't it?
Yes, but for one detail: upon completion it is possible that arguments
(most likely non-options) are left in @ARGV. What to do with these?

I see three possibilities:

  1. Ignore.
  2. Raise an exception.
  3. Leave/put them in the (global) @ARGV.

Personally, I'd prefer 2, meaning that GetoptionsFromString requires
the string to be completele dealt with.
Please share your ideas.

-- Johan

Reply via email to