in reply to Getopt::Declare parameter variables

#!/your/perl/here use strict; use warnings; use Getopt::Declare; unshift @ARGV, -one => 1, -two => 2 # <- defaults unless "@ARGV" =~ /(-help|-version)/; my $options = Getopt::Declare->new(<<'SPEC'); -one <one:i> first param: (default = 1) [repeatable] {$::one = $one; defer{ die "\t -one ($::one) > -two ($::two)\n" if $::one > $::two } } -two <two:i> second param: (default = 2) [repeatable] {$::two = $two} SPEC print "one = $options->{-one}\n"; print "two = $options->{-two}\n";

Replies are listed 'Best First'.
Re^2: Getopt::Declare parameter variables
by QM (Parson) on Aug 25, 2004 at 17:44 UTC
    Thanks, I knew I didn't have my head on straight!

    There are 2 minor typos in your example, which Getopt::Declare makes easy to find.

    First, there doesn't appear to be a tab between the specifications and the descriptions (but this may be due to the cut and paste).

    Second, a blank line is needed between each parameter spec and the next.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of