Monday, February 7, 2011

PERL : Include HELP in scripts

use Getopt::Long;


my $help = <<EndHelp;
Usage:
SCRIPT.pl <PARAM1> <PARAM2> [-help|-h]
The arguments meaning:
----------------------
<PARAM1> - param1 description
<PARAM2> - param2 description
[-help|-h] - print this help screen
EndHelp
# Verify the ARGS
my $hlp;
my $result = GetOptions( "help|h" => \$hlp );
# Print Help Message
if($result == 0 || $#ARGV == -1 || $hlp)
{
  print $help;
  exit 0;
}
# Input Parameters
my $var1 = $ARGV[0];
my $var2 = $ARGV[1];

No comments:

Post a Comment