in reply to function like GetOption

Command line parsing is a common problem so, not surprisingly, someone's already solved it for you.

There's an entire hierarchy on CPAN dedicated to this, called Getopt. A couple of the more popular modules are: Browse the documentation, and see which one suits your needs.

For any problem in Perl that might have a general solution, it's worthwhile having a look on CPAN. Chances are there's a module that does all the work for you. This is one of the best parts of Perl.