Next | Welcome to my ~/bin | 40 |
There's a hash that defines the meaning of the options:
my %Opts =
('' => [qw(Xm Ym Xv Yv Xs Ys m b r)],
mean => [qw(Xm Ym)],
'm' => [qw(Xm Ym)],
stddev => [qw(Xs Ys)],
's' => [qw(Xs Ys)],
sd => [qw(Xs Ys)],
dist => [qw(Xm Ym Xs Ys)],
line => [qw(m b)],
correlation => [qw(r)],
corr => [qw(r)],
r => [qw(r)],
lr => [qw(m b r)],
variance => [qw(Xv Yv)],
var => [qw(Xv Yv)],
v => [qw(Xv Yv)],
);
To add more options, just extend the hash
Then processing the options looks like this:
if (@ARGV) {
while ($ARGV[0] =~ /^-(\w+)$/) {
if ($Opts{$1}) {
for my $s (@{$Opts{$1}}) {
$V{$s} = 1;
}
} else {
$V{$1} = 1;
}
shift;
}
} else {
$V{$_} = 1 for @{$Opts{""}};
}
$Opts{""} is the default
Next | Menu | Copyright © 2005 M. J. Dominus |