return $content;
}
+###--------------------------------------------------------------------------
+### Simple option parser.
+
+package Odin::OptParse;
+
+sub new {
+ my ($cls, @args) = @_;
+ return bless {
+ cur => "",
+ args => \@args,
+ opt => undef,
+ ok => 1
+ }, $cls;
+}
+
+sub get {
+ my ($me) = @_;
+ if (!length $me->{cur}) {
+ my $args = $me->{args};
+ if (!@$args) { return undef; }
+ elsif ($args->[0] =~ /^[^-]|^-$/) { return undef; }
+ elsif ($args->[0] eq "--") { shift @$args; return undef; }
+ $me->{cur} = substr shift @$args, 1;
+ }
+ my $o = $me->{opt} = substr $me->{cur}, 0, 1;
+ $me->{cur} = substr $me->{cur}, 1;
+ return $o;
+}
+
+sub arg {
+ my ($me) = @_;
+ my $a;
+ if (length $me->{cur}) { $a = $me->{cur}; $me->{cur} = ""; }
+ elsif (@{$me->{args}}) { $a = shift @{$me->{args}}; }
+ else { $a = undef; $me->err("option `-$me->{opt}' requires an argument"); }
+ return $a;
+}
+
+sub rest { return @{$_[0]->{args}}; }
+sub ok { return $_[0]->{ok}; }
+sub bad { $_[0]->{ok} = 0; }
+sub err { $_[0]->bad; print STDERR "$PROG: $_[1]\n"; }
+sub unk { $_[0]->err("unknown option `-$_[0]->{opt}'"); }
+
###----- That's all, folks --------------------------------------------------
1;