User Tools

Site Tools


perl:command_line_options_with_usage
# Tyler Bletsch
use strict;
 
# Get command line options
while ($ARGV[0] =~ /^-(.)(.*)/) {
	shift;
	my ($opt,$param) = ($1,$2);
 
	if ($opt eq 'a') { next; }
	elsif ($opt eq 'b') { next; }
	else { &usage }
}
 
# Check for existance of remaining arguments
&usage unless (@ARGV);
 
###############################################################################
 
sub usage() {
	(my $progName = $0) =~ s#.*[/\\]##;
	print <<EODOC;
TITLE
 
Purpose
 
Usage:
    $progName [options] [arguments]
 
Options:
    a - Does this
    b - Does that
 
Arguments:
    Things
 
EODOC
	exit;
}
perl/command_line_options_with_usage.txt · Last modified: 2009/08/13 09:56 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki