#! /usr/bin/perl #--------------------------------------------------------------------- # $Id: simple 1712 2007-03-22 00:13:26Z cjm $ # # Demonstrate the flexible method of using Getopt::Mixed #--------------------------------------------------------------------- # This next line is only so you don't have to install Getopt::Mixed first: BEGIN {unshift @INC, '../lib'} # Don't do this in your code #--------------------------------------------------------------------- use strict; use Getopt::Mixed 1.006, 'getOptions'; use vars qw( $opt_apples $opt_apricots $opt_b $opt_c $opt_d $opt_file $opt_pears $opt_help $opt_version ); getOptions("apples=f a>apples apricots=f b:i c d:s file=s f>file pears=f", "help ?>help version V>version"); print '$opt_apples = ',$opt_apples,"\n" if defined $opt_apples; print '$opt_apricots = ',$opt_apricots,"\n" if defined $opt_apricots; print '$opt_b = ',$opt_b,"\n" if defined $opt_b; print "\$opt_c\n" if $opt_c; print '$opt_d = ',$opt_d,"\n" if defined $opt_d; print '$opt_file = ',$opt_file,"\n" if defined $opt_file; print '$opt_pears = ',$opt_pears,"\n" if defined $opt_pears; print "\$opt_help\n" if $opt_help; print "\$opt_version\n" if $opt_version; print "ARGV = ",join(' ',@ARGV),"\n";