in reply to uninitialised variable

You have some very good replies already. I would only add that perlcritic picks this up:

$ perlcritic 1178655.pl Code before strictures are enabled at line 1, column 1. See page 429 +of PBP. (Severity: 5) Variable declared in conditional statement at line 5, column 3. Decla +re variables outside of the condition. (Severity: 5)

If you have some odd-looking code like this which does not behave how you expect, perlcritic is a decent (but not infallible) tool to use in order to obtain some hints as to possible problems.