Nickd_69,
Welcome to the Monastery! Since you will very likely get many responses about using CGI to do your argument parsing, let me point out a couple other things:
select can be used to select your default output file handle so you would not have to keep typing print MAIL
Invoking a sub-routine as &subroutine instead of subroutine() exposes the sub to the current @_ and is probably not what you want when debugging problems.
Try to get in the habit of using warnings (use warnings;) and also strict (use strict;) since it will point out lots of errors for you. Perhaps you might also like use diagnostics;
Take a look at Variable Scoping basics from our Tutorials section and the external Coping with Scoping by Dominus. Your use of globals will likely make debugging harder when you find that you have inadvertently used the same variable name and stepped on it elsewhere
Finally, reading the Perlmonks FAQ will save you a lot of headache in not getting the answers you are seeking. There is a LOT of information here.