15/17

9. Getopt::Euclid looks cool too (Chapter 14)

  • Embed your usage statement in your POD, and then use it directly:

        use Getopt::Euclid;
        if ($ARGV{-i}) {
            print "Interactive mode...\n";
        }
        for my $x (0..$ARGV{-size}{h}-1) {
            for my $y (0..$ARGV{-size}{w}-1) {
                do_something_with($x, $y);
            }
        }
        __END__
        =head1 NAME
        yourprog - Your program here
        =head1 VERSION
        This documentation refers to yourprog version 1.9.4
        =head1 USAGE
            yourprog [options]  -s[ize]=<h>x<w>  -o[ut][file] <file>
        =head1 REQUIRED ARGUMENTS
        =over
        =item  -s[ize]=<h>x<w>
        Specify size of simulation
        =for Euclid:
            h.type:    int > 0
            h.default: 24
            w.type:    int >= 10
            w.default: 80