use Getopt::Long; my %options; $ret=GetOptions( "i" => \$options{i}, "o=s" => \$options{o}, "p=s" => \$options{p}, "h" => \$options{h} ); if ( $ret=="" || exists $options{'h'} || !@ARGV) { print " \nCommand line options: -i interactive -o file give a file -h help -p value personal exit; } else { if (exists $options{i}) { print "i is enabled\n"; } if (exists $options{o}) { print "o is enabled file is $options{o}\n"; } if (exists $options{p}) { print "p is enabled value is $options{p}\n"; } }