If you do
which is a good idea, you need to declare vars before using them, like C.
I can recommend the Llama book (Learning Perl) if you haven't already got it.
Here's the lang pages, inc examples: http://perldoc.perl.org/
You can use them instead of buying Programming Perl, but I highly recommend Perl Cookbook if you are serious about learning Perl; lots of pre-worked examples with explanations.