in reply to GetOpt Organization

Not used this before myself, no idea whether there is an established pattern. Here is my proposal:

use strict; use warnings; use Getopt::Long; my %parms = ( "os|o" =>\(my $showos =0), "rel|r" =>\(my $showrel =0), "arch|a" =>\(my $showarch =0), "iface|i"=>\(my $showiface=0), "hd|h" =>\(my $showhd =0), "mem|m" =>\(my $showmem =0), "user|u" =>\(my $showuser =0), ); GetOptions ( %parms, "all|A" => sub { $$_=1 for values %parms }, "help|h" => sub { &help; exit 0; } ); $showos=5; print "$showos,$showrel,$showarch,$showiface,$showhd,$showmem,$showuse +r\n";

Replies are listed 'Best First'.
Re^2: GetOpt Organization
by RichardK (Parson) on Mar 09, 2015 at 14:16 UTC

    Minor bug - The first param to GetOptions needs to be a reference to a hash \%parms

      That may be so but the code seems to work anyway.

      UPDATE: ...reason being that there are several ways to use GetOpt::Long, one of which does not require a hash ref as first parameter.

        Sorry about that, you're right I misunderstood what you did.