You could just use Getopt::Long and localize the parameters first set of parameters in @ARGV, get the next set localize @ARGV again. For example:
use strict; use warnings; use Getopt::Long; my @current_params; my $counter; while ( @current_params = get_next_set() ) { $counter++; print "\nloop $counter:"; local @ARGV = @current_params; my ($alpha,$beta,$gamma); GetOptions ( 'Alpha|a' => \$alpha, 'Beta|b' => \$beta, 'Gamma|g' => \$gamma, ); if ( $alpha ) { print "ALPHA FOUND." } if ( $beta ) { print "BETA FOUND." } if ( $gamma ) { print "GAMMA FOUND." } } ######################## sub get_next_set ######################## { my @temp_set; while ( @ARGV ) { push @temp_set,shift @ARGV; last if $temp_set[$#temp_set] !~ /^-/ and defined $ARGV[0] and $ARGV[0] =~ /^-/; } return @temp_set; } ##get_next_set
Which produces something like the following:
E:\>232942.pl -a -b FOO BAR -a -b -g BAR FOO -a -g FOO loop 1:ALPHA FOUND.BETA FOUND. loop 2:ALPHA FOUND.BETA FOUND.GAMMA FOUND. loop 3:ALPHA FOUND.GAMMA FOUND. E:\>
Anyhow this is the first thing that came to mind when I read your post. And I would like to hear what problems, nuances, I might have overlooked.

-enlil


In reply to Re: How to parse these command-line options? by Enlil
in thread How to parse these command-line options? by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.