#!/usr/bin/perl use warnings; use strict; =head1 NAME param-example.pl - An example of how to use command line parms and getopts concurrently. =head1 SYNOPSIS param-example.pl [-u username] [-p password] [username] [password] Options: -help brief help message -man full documentation -user use name -password password =head1 VERSION author dwm042 date 10/6/2007 modified N/A =head1 DESCRIPTION param-example.pl - An example of how to use command line parms and getopts concurrently. This program looks first for command line parameters to define username and password and then looks for flags to define the username and password. =cut use Getopt::Long; use Pod::Usage; my $help = 0; my $man = 0; my $user = 0; my $passwd = 0; GetOptions( 'help|?' => \$help, man => \$man, "user=s" => \$user, "passwd=s" => \$passwd, ) or pod2usage(2); pod2usage( -exitval => 0, -verbose => 1 ) if $help; pod2usage( -exitval => 0, -verbose => 2 ) if $man; my $username = shift; my $password = shift; $username = $user unless defined($username); $password = $passwd unless defined($password); pod2usage(1) unless $username; pod2usage(1) unless $password;