in reply to Use of uninitialized value errors

Either do what blackjudas showed above, or:
  1. Initialize your variables, which doesn't look reasonable.
  2. no warnings qw(uninitialized); #(what I would do)
perldoc perllexwarn for more information on #2. I would suppress warnings in just that block, so the rest of your code won't be affected.