In addition to what mortiz said, if you haven't already done so, read strict and my. That should give you a better understanding of why you should use strict and why you get this error.
Also, you should:
use warnings;
Comment on Re: "use strict" and undeclared variables