in reply to if not defined question

The test at line 100 doesn't prevent line 103 executing. Maybe you want to bail (use return, die or exit as appropriate) after the print at line 101?

Perl is the programming world's equivalent of English