Opt - Get command line options and their values
This module allows you to read command-line options and their values. This module can handle any command-line interface.
use Opt; use strict; my ($error, $opt1, $opt2, $opt3, @info) = &Opt::GetOpt("-opt1:b, -opt2:s=string2, -opt3:s", "req 1, xor 2 3", @ARGV); if ($error) { print "Errors detected in specifying options.\nUsage:<usage string>"; } else { ### Rest of the code if ($opt1) { if ($info[1]==1) { ### If the value is a default value print "Default value for opt2 is taken\n"; } elsif ($info[1]==3) { ### If the value is not default print "Non-default value as given = $opt2"; } } }
The module can be installed using the standard Perl procedure: perl Makefile.PL make make test # No tests defined in the version 0.1.1 make install # You may need to be root make clean # or make realclean Windows users without a working "make" can get nmake from: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
The Synopsis above gives an example of how to use the perl module and the function GetOpt. In addition, extensive documentation is provided in the perl module itself. The perl module can be usually found in the path /usr/lib/perl/5.8/ or /usr/lib/perl/5.8.8/ etc.
This is the 0.1.1 version distribution of the Opt.pm module
Balaji Ramasubramanian (balaji.ramasubramanian@gmail.com)
Of course, I'll welcome e-mails. And now, I have a website. If you have a question or suggestion, please let me know. http://balaji.ramasubramanian.googlepages.com/
To install Opt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Opt
CPAN shell
perl -MCPAN -e shell install Opt
For more information on module installation, please visit the detailed CPAN module installation guide.