Getopt::Long or Getopt::Std. They both support the kinds of solutions you want to do, plus they provide the abilities to do more. There is absolutely no reason to reinvent the wheel, especially not this one.
My criteria for good software:
Does it work?
Can someone else come in, make a change, and be reasonably certain no bugs were introduced?