Probably overkill, but you could use something like
Getopt::Declare to spec your options and then parse them. G::D allows you to create a parser -- it's not just for command line arguments.
Update: Corrected link (thanks sk).
-QM
--
Quantum Mechanics: The dreams stuff is made of