Have a look at using the Getopt::Long module, specifically this.
Update: Link fixed.
In reply to Re: getopts and -? by kejohm in thread getopts and -? by viffer