#! /usr/bin/perl

# pl -- template file for perl scripts 
# $Id$
# Carlos Duarte <cgd@mail.teleweb.pt>, 990218

use strict;

sub usage {
	print <<EOM;
usage: $0 [-n] [-h] options args ... 

  -h      this help
  -n      dont! do nothing. 
EOM
	@_ and print "\n", join("\n", @_), "\n";
	exit;
}

O: while (defined(my $opt = shift)) {
	$opt eq "-h" and usage;

	# option with no args... (flag)
	$opt eq "-n" and do { next O; }; 

	# option with one arg
	$opt =~ /^-f/ and do {
		$opt =~ s///; ($opt eq "" && !defined($opt = shift)) and usage;
		# use $opt
		next O; 
	}; 

	## more options here... 

	$opt eq "--" and last O;
	$opt =~ /^-/ and usage; 
	unshift(@ARGV, $opt); 
	last O; 
}

## if _must_ accept arguments, after options
#@ARGV == 0 and usage; 

my $arg; 
while (defined($arg = shift)) {
	# ... 
}
