Also, your "return 2" and "return 0" can not be used inside the main portion of your code, only from inside a subroutine. Maybe you want to use exit instead?
exit - perldoc.perl.org