On Thu, Mar 16, 2006 at 10:55:15AM +0100, Johan Vromans wrote:

> 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);

      (GetOptions(@opts), @ARGV)

>   }
> 
> 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.

    4. my ($result, @argv) = GetoptionsFromString($string, @opts);

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

Should it actually be GetOptionsFromString?

(or maybe get_options_from_string) </ducks>

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to