Thursday, September 22, 2011

getopts in perl

my %options=();
getopts("p:a:r:", \%options);

# test for the existence of the options on the command line.
# in a normal program you'd do more than just print these.
print "-p $options{p}\n" if defined $options{p};
print "-a $options{a}\n" if defined $options{a};
print "-r $options{r}\n" if defined $options{r};

No comments:

Post a Comment