in reply to Bad Code?

Your code looks fine to me. Remember that in Perl, there is more than one way to do it (TIMTOWTDI).

Update: I agree with bear0053, that you should use strict, and use warnings is also a good idea.