in reply to finding null vars

"use strict" is not enough. Try

#!/usr/bin/perl -w use strict; # your code follows

And the Perl compiler should tell you if a variable is not initialized