| 
#!/usr/bin/perl  
use Getopt::Long (); 
 
my ($opt_debug, $opt_verb, $opt_help, $opt_pages) = (0) x 4; 
my $opt_color = ''; 
my @opt_file  = (); 
 
#$opt = param('OPT'); 
 
$ok = Getopt::Long::GetOptions( 
                'debug!'  => \$opt_debug,  
                'verbose+'=> \$opt_verb ,  
                'help'    => \$opt_help ,  
                'pages=i' => \$opt_pages,  
                'color=s' => \$opt_color, 
                'file=s'  => \@opt_file ); 
 
print        "\t-debug   = $opt_debug\n", 
        "\t-verbose = $opt_verb\n", 
        "\t-help    = $opt_help\n", 
        "\t-pages   = $opt_pages\n", 
        "\t-color   = $opt_color\n", 
        "\t-file    = ", join(',',@opt_file),"\n"; 
 
Usage() if !$ok || $opt_help; 
 
#======================================================================= 
sub Usage() { 
#======================================================================= 
print <<EOF; 
Usage: $0 [options] [filename] 
 
This program does following ..... 
 
Options are:  
        -help                Print this help message. 
        -debug                Turn on debugging mode. This option is negatable. 
                        i.e accepts --nodebug 
        -verbose        Turn on verbose mode. This option is incremental. 
                        i.e can appear multiple times.  
                        In this case Getopt returns count of appearances 
                        instead of 1 
        -pages                Number of pages to print. Numeric value 
        -color                Use this color. String value 
        -file                Input file name(s). Accepts multiple values. 
 
$0 -help -debug -color=blue -pages=5 -file=/usr/bin/ls -file=/usr/lib/gcc 
EOF 
} 
  | 
 |